Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!amdahl!oliveb!sun!limes From: limes@sun.uucp (Greg Limes) Newsgroups: comp.lang.c Subject: Re: Put your code... (was Re: gotos Message-ID: <51306@sun.uucp> Date: 29 Apr 88 02:39:28 GMT References: <422@yunexus.UUCP> <4700011@uiucdcsm> Reply-To: limes@sun.UUCP (Greg Limes) Organization: Sun Microsystems, Mountain View Lines: 24 In article <4700011@uiucdcsm> wsmith@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@sun.com] frames to /dev/fb