|
Jérôme Vuarand wrote:
Now that I see a concrete example, a question comes to my mind : does a called function (in that case require) has any mean to access the local variables of one of its caller ? I would say that no since the local variables are not part of any environment. Is that right ?
Right. You can always tell whether a local variable is accessible from a certain spot by looking at the source code: the local's scope needs to start above the spot in question and end after it, which rules out (for instance) a spot and a local variable in different files. There is a cheat for this, though -- debug.getlocal can be used to get a caller's locals (or those of the caller's caller, and so on down the stack). --Aaron