Re: I'd give my right arm for a continue statement
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: I'd give my right arm for a continue statement
 
- From: Tony Finch <dot@...>
 
- Date: 2011年1月28日 19:29:51 +0000
 
On 2011年1月27日, Sean Conner wrote:
>
> 	x = 0;
> 	do
> 	{
> 	 body1();
> 	 if (x < 30) continue;
> 	 body2();
> 	 x++;
> 	} while(x < 50);
>
> 		x = 0;
> 	CONTINUE:
> 		body1();
> 		if (x < 30) goto CONTINUE;
> 		body2();
> 		x++;
> 		if (x < 50) goto CONTINUE;
No, that should be:
 		x = 0;
 	start:
 		body1();
 		if (x < 30) goto CONTINUE;
 		body2();
 		x++;
	CONTINUE:
 		if (x < 50) goto start;
> If you keep the similar behavior of "continue" in C into Lua, then:
Note that there is a significant difference in the scoping rules between C
and Lua:
	do {
		int i;
	} while (f(i)); // ERROR: i is not in scope
	repeat
		local i
	until f(i) -- ok: i is in scope
And this difference is one of the reasons that the hypothetical `continue`
would be more awkward in Lua than in C.
Tony.
-- 
f.anthony.n.finch <dot@dotat.at> http://dotat.at/
HUMBER THAMES DOVER WIGHT PORTLAND: NORTH BACKING WEST OR NORTHWEST, 5 TO 7,
DECREASING 4 OR 5, OCCASIONALLY 6 LATER IN HUMBER AND THAMES. MODERATE OR
ROUGH. RAIN THEN FAIR. GOOD.
- References:
- Re: I'd give my right arm for a continue statement, steve donovan
 
- Re: I'd give my right arm for a continue statement, HyperHacker
 
- Re: I'd give my right arm for a continue statement, Michal Kottman
 
- Re: I'd give my right arm for a continue statement, steve donovan
 
- Re: I'd give my right arm for a continue statement, Alexander Gladysh
 
- Re: I'd give my right arm for a continue statement, steve donovan
 
- Re: I'd give my right arm for a continue statement, Roberto Ierusalimschy
 
- Re: I'd give my right arm for a continue statement, Axel Kittenberger
 
- Re: I'd give my right arm for a continue statement, Axel Kittenberger
 
- Re: I'd give my right arm for a continue statement, Lucas Zawacki
 
- Re: I'd give my right arm for a continue statement, Sean Conner