lua-users home
lua-l archive

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

On Wed, Jun 15, 2011 at 1:29 PM, Roberto Ierusalimschy
<> wrote:
> we are also considering to enforce a single occurence of a label name in
> each function, to avoid ambiguities. (That does not change the visbility
> rules; it is only an extra restriction.)

With locals, I tend to appreciate that I can override them in the same scope:

  local x, err = f(); if not x then print(err) end
  local y, err = g(); if not y then print(err) end  -- note: "err"
  for _, v in ipairs(t) do; for _, vv in ipairs(v) do print(vv) end
end  -- note "_"

With labels, I may want that too, but the backward + forward lookup
causes ambiguity:

  for x=1,10 do for y=1,10 do
    if not f(x,y) then goto done end
  end end @ done

  for x=1,10 do for y=1,10 do
    if not g(x,y) then goto done end    -- go where?
  end end @ done

In the "Lua 5.2.0 (beta-rc1) GOTO" discussion, it's proposed that
labels also be used as a way to inject lineinfo debuginfo into the
bytecode for code generation:

  @ line123; f(); @ line124; g(); @ line123; h()

Enforcing a single occurrence of label names will render the above
example invalid even though there is no ambiguity because there is no
goto that jumps to any of those labels.  True, we could work around
that restriction though:

  @ line123; f(); @ line124; g(); @ line123_; h()