Re: "continue" construct in Lua loops
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: "continue" construct in Lua loops
- From: Philippe Lhoste <PhiLho@...>
- Date: 2006年12月21日 14:46:07 +0100
Javier Guerra a écrit :
On Thursday 21 December 2006 8:21 am, Roberto Ierusalimschy wrote:
Is there a more elegant way?
No :( (At least you can be confident that the generated opcode is
as good as for a primitive continue ;)
i guess both metalua's and token filter's wizards will soon present their
solutions.
but this is not the first time this has been discussed. i beleive there was a
serious semantic problem; but i can't remember it now
i'd really wish there was a 'continue' statement, in fact i've been using deep
if's, for me the 'break out of repeat' construct is an improvement!!
Yes, I frown as it was a kind of Faq, but since Leo came with a good
solution, that is even marked as "efficient" by Roberto himself, no problem!
I will add this to my toolbox... ;-)
for i = 0, 9 do repeat
if math.mod(i, 2) == 0 then break end
print(i)
until true end
It has a look of "special loop with continue" syntax... :-)
--
Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr
-- -- -- -- -- -- -- -- -- -- -- -- -- --