lua-users home
lua-l archive

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



On 31-Oct-06, at 4:55 PM, Karel Tuma wrote:

hi listers,

i've found myself doing lot of miserable things today, due to inability of lua to simply break out of multiple nested breakable scopes in one statement.


One reasonably simple way of doing it is to put the multiple nested loops into a function, and returning. You can even use an inline anonymous function:

local eekval = (function()
  while foo() do
    while bar() do
      if baz() then return eek() end
    end
  end
end)()

But I understand that isn't everyone's cup of tea.

finding nothing useful in powerpatches archive i wrote this rather naive and unintrusive patch - so there is generally no reason why it shouldn't work, but i've tested it extensively only with various for/while nested loops.


This topic (or something vaguely related) came up on IRC today so I happen to have this link to the mailing list from a year ago handy:

http://lua-users.org/lists/lua-l/2005-10/msg00037.html

If you follow that thread to the end, you'll find a patch I wrote against Lua 5.1-alpha (link and syntax in this message: http://lua-users.org/lists/lua-l/2005-10/msg00057.html )

I haven't updated that patch to 5.1.1 because there didn't seem to be any demand for it. Of course, it's a lot more intrusive to the language. It shouldn't be too difficult to upgrade.