lua-users home
lua-l archive

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


I'm not awake enough tonight to write it, but I realized that one could write a function pushscope( env ) which, provided it knew the current environment (that's part of the trick to writing it), could construct a new environment tacking the argument onto the top of the stack. That would allow one to write:

	in pushscope( env ) do
		-- the entries in env are now visible as part of the globals and env is now the target for global assignments
	end

This does not get one dynamic scoping since it isn't visible inside of anything called within the construct, but it does essentially handle the table scope case (http://lua-users.org/wiki/TableScope).

For that matter, pushscope could take a series of scopes to add on.

Mark