Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #139234
| Subject | Re: if cargo blocks |
|---|---|
| Newsgroups | comp.lang.c, comp.lang.c++ |
| References | <q084io$qe1$1@dont-email.me> <1HNVD.208806$DWh1.86871@fx36.am4> <q08b57$54q$1@dont-email.me> |
| From | Bart <bc@freeuk.com> |
| Message-ID | <gKTVD.49503$gX2.21792@fx32.am4> (permalink) |
| Organization | virginmedia.com |
| Date | 2018-12-29 23:49 +0000 |
Cross-posted to 2 groups.
On 29/12/2018 17:34, Rick C. Hodgin wrote:
> On 12/29/2018 11:56 AM, Bart wrote:
>> On 29/12/2018 15:42, Rick C. Hodgin wrote:
>>> if (some_test1)
>>> in { setup_for_test1 }
>>> out { cleanup_for_test1 }
>>> enter { related_code_if_block_entered1 }
>>
>> Wouldn't these be better as in, enter, out?
>
> They're labeled. They go in the correct flow order no matter what order
> they appear in source code.
>
> Another option that should be added for if cargo blocks is the ability
> to continue testing at the next else-if/else condition. I think it
> should be "prevtest;" and "nexttest;" and "gotest label;" where label
> by the name given to a block. Also, the "out;" keyword which operates
> like break; for a loop, except it works within the if blocks:
>
> if (x)
> {
> nexttest; // Continues with the "else if (y)" test
> gotest zlabel; // Go to the "else if (z)" test
>
> } else if (y) {
> // Code here
> prevtest; // Retest "else if (y)" block
> gotest last; // Go to the else block
>
> } else if (z) zlabel {
> if (whatever)
> out; // Leave the if-block
>
> } else last {
> // Code here
> }
>
> Note the above are all unconditional branches and will perform
> their action when encountered, so in this example "gotest zlabel"
> and "gotest last" would never be executed. They are just examples
> showing how branching could work from one place to another.
You've just reinvented spaghetti code I think. And loops.
But you don't need new features for that. I assume 'nexttest' and
'prevtest' and 'gotest' are special kinds of gotos? How does it work
with nested if/else statements?
Never mind; this is too much of a crazy idea to pursue further.
BTW here's how you can express your example in current C:
if (x)
{
goto ylabel; // Continues with the "else if (y)" test
goto zlabel; // Go to the "else if (z)" test
} else ylabel: if (y) {
// Code here
goto ylabel; // Retest "else if (y)" block
goto last; // Go to the else block
} else zlabel: if (z) {
if (whatever)
goto out; // Leave the if-block
} else last: {
// Code here
}
out:;
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-29 10:42 -0500
Re: if cargo blocks David Brown <david.brown@hesbynett.no> - 2018-12-29 17:26 +0100
Re: if cargo blocks Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2018-12-29 16:32 +0000
Re: if cargo blocks Bart <bc@freeuk.com> - 2018-12-29 16:56 +0000
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-29 12:34 -0500
Re: if cargo blocks Bart <bc@freeuk.com> - 2018-12-29 23:49 +0000
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-29 18:52 -0500
Re: if cargo blocks Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2018-12-30 00:12 +0000
Re: if cargo blocks rbowman <bowman@montana.com> - 2018-12-29 19:04 -0700
Re: if cargo blocks Ralf Goertz <me@myprovider.invalid> - 2018-12-30 06:12 +0100
Re: if cargo blocks David Brown <david.brown@hesbynett.no> - 2018-12-30 15:23 +0100
Language (Was: if cargo blocks) gazelle@shell.xmission.com (Kenny McCormack) - 2018-12-30 15:39 +0000
Re: Language (Was: if cargo blocks) rbowman <bowman@montana.com> - 2018-12-30 11:23 -0700
Re: if cargo blocks Ralf Goertz <me@myprovider.invalid> - 2018-12-31 05:21 +0100
Re: if cargo blocks David Brown <david.brown@hesbynett.no> - 2018-12-31 18:09 +0100
Re: if cargo blocks rbowman <bowman@montana.com> - 2018-12-31 12:22 -0700
Re: if cargo blocks Ralf Goertz <me@myprovider.invalid> - 2019-01-01 12:04 +0100
Re: if cargo blocks rbowman <bowman@montana.com> - 2018-12-31 11:50 -0700
Re: if cargo blocks Ralf Goertz <me@myprovider.invalid> - 2019-01-01 11:43 +0100
Re: if cargo blocks Ralf Goertz <me@myprovider.invalid> - 2019-01-01 14:27 +0100
German grammar (Was: if cargo blocks) gazelle@shell.xmission.com (Kenny McCormack) - 2019-01-01 14:17 +0000
Re: if cargo blocks rbowman <bowman@montana.com> - 2019-01-01 11:04 -0700
Re: if cargo blocks fir <profesor.fir@gmail.com> - 2019-01-01 10:38 -0800
Re: if cargo blocks rbowman <bowman@montana.com> - 2019-01-01 10:57 -0700
DDR Ralf Goertz <me@myprovider.invalid> - 2019-01-01 21:18 +0100
Re: DDR rbowman <bowman@montana.com> - 2019-01-01 16:18 -0700
Re: if cargo blocks Siri Cruise <chine.bleu@yahoo.com> - 2019-01-01 16:30 -0800
Re: if cargo blocks rbowman <bowman@montana.com> - 2018-12-30 11:09 -0700
Re: if cargo blocks Ralf Goertz <me@myprovider.invalid> - 2018-12-31 05:43 +0100
Re: if cargo blocks rbowman <bowman@montana.com> - 2018-12-31 12:06 -0700
Linguistics. Re: if cargo blocks Siri Cruise <chine.bleu@yahoo.com> - 2019-01-01 16:27 -0800
Re: Linguistics. Re: if cargo blocks rbowman <bowman@montana.com> - 2019-01-01 22:30 -0700
Re: Linguistics. Re: if cargo blocks Louis Krupp <lkrupp@nospam.pssw.com.invalid> - 2019-01-02 04:18 -0700
Re: if cargo blocks Bart <bc@freeuk.com> - 2018-12-30 02:07 +0000
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-29 21:59 -0500
Re: if cargo blocks rbowman <bowman@montana.com> - 2018-12-29 13:57 -0700
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-29 16:03 -0500
Re: if cargo blocks Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2018-12-29 21:32 +0000
Re: if cargo blocks rbowman <bowman@montana.com> - 2018-12-29 16:06 -0700
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-29 18:15 -0500
Re: if cargo blocks fir <profesor.fir@gmail.com> - 2018-12-29 15:32 -0800
Re: if cargo blocks fir <profesor.fir@gmail.com> - 2018-12-29 15:34 -0800
Re: if cargo blocks fir <profesor.fir@gmail.com> - 2018-12-29 15:38 -0800
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-29 15:40 -0800
Re: if cargo blocks fir <profesor.fir@gmail.com> - 2018-12-29 15:45 -0800
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-29 18:36 -0500
Re: if cargo blocks fir <profesor.fir@gmail.com> - 2018-12-29 15:42 -0800
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-29 15:45 -0800
Re: if cargo blocks fir <profesor.fir@gmail.com> - 2018-12-29 15:54 -0800
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-29 18:58 -0500
Re: if cargo blocks fir <profesor.fir@gmail.com> - 2018-12-29 16:01 -0800
Re: if cargo blocks "Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid> - 2018-12-29 13:36 -0800
Re: if cargo blocks "I Set My Girlfriend's Pantyhose on Fire" <cdalten@gmail.com> - 2018-12-29 13:16 -0800
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-29 16:32 -0500
Re: if cargo blocks Siri Cruise <chine.bleu@yahoo.com> - 2018-12-30 13:00 -0800
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-30 16:12 -0500
Re: if cargo blocks Siri Cruise <chine.bleu@yahoo.com> - 2018-12-30 13:31 -0800
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-30 16:45 -0500
Re: if cargo blocks Bart <bc@freeuk.com> - 2018-12-30 22:17 +0000
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-30 17:22 -0500
Re: if cargo blocks "Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid> - 2018-12-30 20:25 -0800
Re: if cargo blocks Ian Collins <ian-news@hotmail.com> - 2019-01-03 09:50 +1300
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-01-02 15:54 -0500
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-01-02 16:29 -0500
Re: if cargo blocks mark.bluemel@gmail.com - 2019-01-03 00:44 -0800
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-01-03 08:17 -0500
Re: if cargo blocks mark.bluemel@gmail.com - 2019-01-03 05:40 -0800
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-01-03 09:15 -0500
You are so full of shit (Was: if cargo blocks) gazelle@shell.xmission.com (Kenny McCormack) - 2019-01-03 13:42 +0000
Re: if cargo blocks fir <profesor.fir@gmail.com> - 2019-01-03 12:27 -0800
Re: if cargo blocks Ian Collins <ian-news@hotmail.com> - 2019-01-04 11:11 +1300
Re: if cargo blocks "Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid> - 2019-01-03 14:37 -0800
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-01-03 17:48 -0500
Re: if cargo blocks fir <profesor.fir@gmail.com> - 2019-01-03 14:59 -0800
Re: if cargo blocks mark.bluemel@gmail.com - 2019-01-03 00:44 -0800
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-01-03 08:19 -0500
Re: if cargo blocks mark.bluemel@gmail.com - 2019-01-03 05:43 -0800
Re: if cargo blocks "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2019-01-03 05:51 -0800
Re: if cargo blocks "Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid> - 2019-01-03 13:22 -0800
Re: if cargo blocks Ian Collins <ian-news@hotmail.com> - 2019-01-04 11:10 +1300
csiph-web