Put your code... (was Re: gotos
Greg Limes
limes at sun.uucp
Fri Apr 29 12:39:28 AEST 1988
In article <4700011 at uiucdcsm> wsmith at uiucdcsm.cs.uiuc.edu writes:
> procedure () {
> prolog code
> do {
> main body
> } while (0);
> epilog code
> }
>
>
>A break or continue inside the 1 time only do-while will jump
>to the epilog code. I think this is only an academic curiosity, and
>I haven't ever seen code actually using this construct. Has anyone
>actually written code with this in it? The optimizer should generate
>the same code as if goto's were used directly.
I used this particular dodge to get around some heavy nesting in a
previous job doing high speed network stuff, then started using it for
some of the utilities. Nice when you have an inner routine that
processes something in nineteen different steps, and if any of them
fails you just want to abort the process, clean up, and return a
failure. I still occasionally use it in quick utilities, although there
is nearly always a better way to do what I want.
--
Greg Limes [limes at sun.com] frames to /dev/fb
More information about the Comp.lang.c
mailing list