lua-users home
lua-l archive

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


BA> Just out of interest, what happens in the following example?

BA> function foo()
BA>   local foo2 = function()
BA>            while true do
BA>                 break 2
BA>            end
BA>         end
BA>   while true do
BA>         foo2()
BA>   end
BA> end
        

BA> Does the "break 2" exit foo()? Or just foo2()?

BA> I would expect an error to be generated by this code. 'break N'
BA> should not be expected to cross call frame boundary for a simple
BA> reason that the context of a function call is generally unknown.

That is how Lua behaves at trying to run the above code. A compilation
error occurs: "test:5: no loop to break near `end'".

Leszek