goto's in 'C'
Thomas M. Breuel
breuel at harvard.ARPA
Sun Jan 20 22:36:00 AEST 1985
>[Rob Warnock:]
>The incidence of the "goto" in C code is so rare anyway, I dare say
>we could abolish it altogether (replacing it with BLISS's "leave")
>and not miss the loss. (I certainly never missed it in BLISS.)
I would miss it. I have never used it for breaking out of loops or
making loops in the conventional sense. It is extremely useful, though,
for 'hardcoding' finite state machines. If they contain more than say 3
or 4 states, the use of structured constructs is awkward. One example
where I have used 'goto' is in a non-recursive threading garbage
collector.
Indeed, rather than abolishing it, what about permitting indirect
goto's (something which, so rumour has it, existed in some older
versions of the 'C' compiler). Why? Well, it is useful if you have to
maintain your own evaluation stack or avoid explicit recursion.
Thomas.
More information about the Comp.lang.c
mailing list