[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Q: Lua 5.2 thread environments...
- From: Jerome Vuarand <jerome.vuarand@...>
- Date: Thu, 31 Mar 2011 14:18:52 +0200
2011/3/31 Anthony Howe <firstname.lastname@example.org>:
> I have a related problem with function environments in 5.1. How to get
> function environments to inherit the environment of the caller and NOT
> that of where it was defined.
Inside your function, you can get the environment of the caller with
getfenv, by passing it a number. You can then replace the current
function environment with that. For example :
-- from now on, all globals are accessing the caller's environment