Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!pacbell!att-ih!att-cb!clyde!watmath!rbutterworth From: rbutterworth@watmath.waterloo.edu (Ray Butterworth) Newsgroups: comp.lang.c Subject: Re: Another "D" idea (Oh no, not again!) Message-ID: <17900@watmath.waterloo.edu> Date: 29 Mar 88 14:54:00 GMT References: <1170@ucsfcca.ucsf.edu> <316@wsccs.UUCP> <2571@cognos.UUCP> Organization: U of Waterloo, Ontario Lines: 40 In article <2571@cognos.UUCP>, brianc@cognos.uucp (Brian Campbell) writes: > In article <316@wsccs.UUCP> val@wsccs.UUCP (Val Kartchner) writes: > > I also think that there should be something like "break 'n';" (Where > > 'n' is a constant integer. Variables would be interesting and floats > > highly ambiguous.) I've often been deep in multiple loops, and wanted > > to get out a few levels. > My suggestion was to add labels to looping constructs: > while (...) :top > while (...) > break :top; > if (...) > continue :top; > The label is far less confusing and requires less maintenance than > specifying the number of levels to exit. It should also make the > compiler's job easier since it is specifically told that interior > statement blocks may be exited abnormally. But that is not really any clearer than what is already available in the language: for ( ; 0 != (file=fopen(...)); fclose(file)) samefile: { while (0 != (line = fgetl(...))) sameline: { for (index=0; 0 != (c=line[index]); ++index) samechar: { ... if (blah()) goto nextfile; blahblah(); if (blahblahblah()) goto sameline; ... nextchar:; } nextline:; } nextfile:; } And I don't feel the slightest guilt in using "goto" in this way.