lua-users home
lua-l archive

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

> I've read the following text on LuaFiveFeatures at
> > - declaration of globals: we introduced global declarations:
> > global a,b,c
> > global a,b,c in T
> > global in T        -- change the default
> > So, "global in nil" forces declarations for every variable;
> > "global in {}" puts all undeclared variables into a private table;
> > "global sin, cos in math" allows the unqualified use of the
> > names "sin" and "cos".
> Apparently this has not gone into Lua 5.0. The interpreter
> complains as "global"  was not a keyword (which is not according
> to the reference manual). Have these features been postponed?
> Is there some workaround in the current Lua version for these
> functionalities?

IIRC the "global" keyword was to be added to enable users to optionally
turn the default declaration of variables in the global namespace on and
off, i.e. undeclared locals cause an error instead of being declared. It
then got extended so that you could use it to declare variables in
specified namespaces and then it was completely replaced by
environments, ie. setfenv()