lua-users home
lua-l archive

Re: function kidnapping

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


> -- Assuming tag methods in place to allow swapping of global table via
> -- a function "setglobaltable".
> function wrapper(func, ...)
> local oldtable = setglobaltable(t)
> local val = call(func, arg)
> setglobaltable(oldtable)
> return val
> end
	With this wrapper, when you swap the global table you'll loose
(while executing the function, of course) all global functions, like
print, gsub, write etc. I think it would be better not to change the
global environment but to check if the global exists. If it doesn't,
so try the local value.
	Tomas

AltStyle によって変換されたページ (->オリジナル) /