lua-users home
lua-l archive

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


On Fri, Nov 19, 2010 at 2:20 AM, Axel Kittenberger <axkibe@gmail.com> wrote:
> wait, +0 is something different than -0? No please not.

Another numbering scheme may be better, but I think now that numbered
scopes are less readable/decipherable than named scopes.
Interestingly, Lua already has named scopes: they are called lexical
variables.  That leads to this proposal:

  for x=1,10 do
    local cont  -- dummy variable
    for y=1,10 do
      if f(x,y) then break x end    -- jump to end of x scope (i.e.
break outer loop)
      if g(x,y) then break cont end   -- jump to end of cont scope
(i.e. continue outer loop)
    end
  end

which may warrant serious consideration.  It opens up some other
possibilities too, if the language designer chooses to allow it:

  do
    local s
    if a() then break s end   -- break out of non-loop blocks too.
  end

  function f()
    local x
    return function()
      break x  -- could this even be allowed? (break across functions)
    end
  end
  f()()()()()