lua-users home
lua-l archive

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


> A potential solution would be to introduce a new "global" or "unlocal"
> keyword, which would force the compiler to perform a global (_ENV) access,
> overriding the local scope of a variable.
> 
> 
> local a = 'local var'
> do
>   local _ENV = require 'mod'
>   global a
>   print(a)  --> from module
> end

What about this "solution"?

do
  local mod = require 'mod'
  print(mod.a)    --> (no need for comment ;)
end

-- Roberto