[Issue 200] New: Statement *must* follow label

BCS BCS at pathlink.com
Sat Jun 17 11:35:59 PDT 2006


pragma wrote:
> In article <e6v4p9$c5f$1 at digitaldaemon.com>, Frits van Bommel says...
>>Or, you know, you could just use "return" instead of "goto x" :P
> 
> 
> Not always. :)
> 
> The example in the bug report is merely the most simple case for Walter's sake
> Here's a real-world example:
> 
> http://www.dsource.org/projects/ddl/browser/trunk/enki/EnkiParser.d#L91
> 
> The above shows a different variation of a workaround: using "{}".  But the
> problem still stands.  The code generator needs a way to provide a way to jump
> to a known pass/fail point where it is known that there are no other
> instructions that could generate side-effects.  Each "{}" closure also maps to a
> particular production in the input grammar, and has its own variables for input
> capture and rewinding the parse position - that's how I found #199 as well.
> 
> - EricAnderton at yahoo

any reason to not allow this?

foo: 	{
	// bail out of this scope
		if(i==0) break foo;

		writef("i!=0\n");

		(i<0)?1++:i--;

	// same effect as continue so no need for that
		goto foo;
	}

Yes its a bit contrived, but the idea could make some more complicated 
code (auto or hand generated) a bit cleaner. I have a few times put 
something in a function just so that a return could be used to leave the 
scope.



More information about the Digitalmars-d-bugs mailing list