lua-users home
lua-l archive

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


Luiz Henrique de Figueiredo wrote:
> 
> >I think people don't generally appreciate how serious
> >of a problem the current semantics are.  Accidental
> >use of global variables is a sleeper: it may be
> >present in your code for a long time and not show up
> >until you make completely unrelated changes to your
> >code.
> 
> If you're willing to use a "global" declaration, then something very similar
> can be done right now: Instead of a "global" keyword, use a "global" function,
> with the syntax
>         global "myvar"  -- one name only
> or
>         global{"a","b"} -- several names

Or the simple way:

	global = globals()
	...
	global.x = 1
	print(global.y)

Ciao, ET.