lua-users home
lua-l archive

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


> -----Original Message-----
> From: lua-l-bounces@lists.lua.org [mailto:lua-l-bounces@lists.lua.org] On
> Behalf Of Dirk Laurie
> Sent: maandag 24 november 2014 7:40
> To: Lua mailing list
> Subject: Feature request: enhanced break
> 
> Optional integer constant after "break" specifies number of enclosing
> loops to break. `break 1` means the same as `break` without a number.
> 
> Example: find an item in a table of lists, with shortcut exit from a list.
> 
> for k,a in pairs(t) do
>     for n,b in ipairs(a) do
>        if futile(b) then break end
>        if found(b) then row,col = k,n; break 2; end
>    end
> end

Seems a bit errorprone to me. Doing maintenance, adding a level due to another loop wrapping some existing piece of code. Now the levels I have for break no longer match...
I'd go for the already mentioned `goto` approach, as the more transparent solution.

Thijs