lua-users home
lua-l archive

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


"John D. Ramsdell" wrote:
>
> On another subject, can we agree that Lua variables do not have nested
> scope?

He?  Of course they have nested scope.  Or how would you call this?

  i="level0"
  do
    local i="level1"
    while foo do
      local i="level2"
      if bar then
        local i="level3"
        function baz()
          local i="level4"
          print i -- level4
        end
        print i -- level3
      else
        print i -- level2
      end
      print i -- level2
    end
    print i -- level1
  end
  print i -- level0

Ciao, ET.