Oh nooo! (gotos)
Jeff Lewis
lewie at pur-ee.UUCP
Thu Sep 7 05:02:38 AEST 1989
[Dave Jones offers an example of what he thinks is a valid use of goto]:
[code trimmed to get to the meat]
> while(rule = (Rule*)Queue_iter_next(&rule_iter)) {
>
> while(rsym = (Symbol*)Queue_iter_next(&rsym_iter)) {
> switch (derives(rsym)) {
> case derives_nothing:
> goto next_rule;
> ....
> }
> }
>
> next_rule: continue;
>
> }
I'm sure this comes up often enough, but the reason I'd say there's nothing
wrong with this type of goto is that it is the equivalent of a continue
with a label, i.e.:
while foo (...) {
while (...) {
...
continue foo;
...
}
}
('foo' is a loop label, which can be used within the loop's scope to alter
flow of control via break or continue)
This, I would say, is just as structured as the simple 'break' and 'continue'
that I presume most people have no problem with. Of course C doesn't offer
this obvious functionality, so you fake it with the occasional 'goto'. Is
there anything wrong with this?
More information about the Comp.lang.c
mailing list