lua-users home
lua-l archive

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




Il sab 13 lug 2019, 12:53 Viacheslav Usov <via.usov@gmail.com> :

This might solve the long-standing problem with globals.

What about something like the following?

x = 0
y = 1
local print, x = print, x
do <error-on-free-name>
  print(x) -- no issue
  print(_ENV.y) -- no issue
  print(y) -- error at compile time
end

I.e. inside the annotated do/end block, any free name raises an error at compile time, instead of being translated to _ENV.y .