lua-users home
lua-l archive

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

 >  repeat
 >    local t = 0
 >    if cond then continue end
 >    local t = 1
 >    ...
 >  until t == 0
 > Then the two t are actually different variables (in the current
 > implementation), and it's not clear to which incarnation the
 > comparison refers.

I'm quite alarmed by this problem.
I was shocked to discover that

  local t = 1
    local t = t + 1
    -- the scope of the inner 't' should end here, but it doesn't
  until t == 1

loops forever printing 2.  
I would have expected that the condition in the 'until' is outside the
scope of the loop body, just like the condition in a 'while'.
In my mind, this is just a mistake in the language design.

Questions like this are why every few years I ask Roberto when we are
going to get a formal semantics for Lua :-)

Norman Ramsey