lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

>> 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?