Oh nooo! (gotos)
Joe English
jeenglis at nunki.usc.edu
Fri Sep 8 11:04:45 AEST 1989
In article <1461 at atanasoff.cs.iastate.edu> hascall at atanasoff.cs.iastate.edu.UUCP (John Hascall) writes:
>In article <12793 at pur-ee.UUCP> lewie at ecn-ee.UUCP writes:
>}[...] the equivalent of a continue with a label, i.e.:
>
>}while foo (...) {
>} while (...) {
>} ...
>} continue foo;
>} ...
>} }
>
> I have often wished for something similar, my thoughts have tended toward
> the synatx:
>
> continue [constant-integer-expression];
> break [constant-integer-expression];
>
> where the [optional] expression indicated how many nested structures
> to continue or break, with the default being 1 (just like the current
> "continue" and "break").
Oog... I don't think that's such a good idea; it's
easier to look for a label than to count sets of braces --
and check that they belong to a while/for/do and not an
if. Plus, if later on you move the code around, adding
or deleting loops, you can introduce errors that aren't
easy to spot.
> While we are on the subject of loops, how do people feel about the
> practice of using #define to "extend" the language? For example:
>
> #define loop for (;;)
> #define exitloop break
I'm against this in general, but I've seen it used
quite effectively in some cases for information hiding:
#define foo_iterate(idx,foo) for (idx=foo.items;idx<foo.lastitem;++idx)
...
foo_iterate(i,qux) {
... use i ...
}
Whether this makes things clearer or more obfuscated
is debatable.
--Joe English
jeenglis at nunki.usc.edu
More information about the Comp.lang.c
mailing list