lua-users home
lua-l archive

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



On 27/08/14 11:34 PM, Coda Highland wrote:
On Wed, Aug 27, 2014 at 7:17 PM, Thiago L. <fakedme@gmail.com> wrote:
It would be cool if you could use break with do ... end for some sort of
"safe goto"

Example:

do
break
local x = "you'll never see me"
print(x)
end
print("something")

Would print "something"

In 5.2+ we have this:

goto x
local x = ""
::x::
print("something")

But it errors instead of doing the scoping stuff you can do with do ... end

(This is probably not something for lua 5 but for lua 6 if/when we get it...
it would probably be less harmful to change goto so that it does an implicit
do ... end scoping thingy)

repeat
   -- statements here
   break
   -- rest of statements skipped
until false

/s/ Adam

until true*, but that's uglier