[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua 5.2 and continue
- From: Alexander Gladysh <agladysh@...>
- Date: Thu, 14 Jan 2010 11:59:55 +0300
>> Linker wrote:
>>> You can just put the loop into a function replacing "continue" with
>>> "return".
>> And add some more code to distinguish return-as-break and
>> return-as-continue, and before you know it the loop is looking quite
>> ugly and you're eyeing Metalua speculatively.
> i = 1
> while i<10 and
> (function()
> if i%2 == 1 then return true end
> if i == 8 then return false end
> print(i)
> return true
> end)() do
> i = i+1
> end
Ouch. Do you realize you're creating a closure on each loop iteration?
Alexander.