[linux-elitists] Goto vs. named scopes

Nick 'Sharkey' Moore sharkey@zoic.org
Sat Jan 11 16:42:06 PST 2003

On Sat, Jan 11, 2003 at 01:24:12PM -0500, Michael Bacarella wrote:
> [Jim Bray wrote:]
> >
> > Allow all scopes to be named, and allow break and continue to operate
> > with those names. Add to those a 'restart' operation and you're pretty
> > much all set.
> > 
> The other common use is in cleanup routines.
> [...] 
> Not the most streamlined example but I think it illustrates
> my point.  Maybe I haven't thought about it enough, but could
> your extensions make that better?

Well, assuming that if 'break <label>' jumps to the end of
the block labelled <label>, 'break' will jump to the end of the
block ...

int stoopid(int foo) 
    outer: {
        r = open_resource();
        if (!r) break;

        inner: {
    	    if (something_didnt_work(r)) break;
	    if (something_else_didn't_work(r)) break;
	    if (resource_mysteriously_went_away_already(r)) break outer;
	    if (goddamn_it(r)) break;
    return foo;

Something like that, anyway.  Most of the time the 'goto release_lock_out'
construction is used it's just away of avoiding incredible levels of
tabbing, though.


More information about the linux-elitists mailing list