lua-users home
lua-l archive

Re: a new proposal for environments

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


>> 3) Inspect which upvalues are used in the resulting function, and use
>> debug.upvaluejoin to convert these faux upvalues in resulting function
>> into the real ones you identified in the call stack.
At first I though it was possible to do that in 5.1 too, but, if I
understand properly, the only way to get this behaviour is by making
an __index metamethod for the "loaded" chunck that will fake upval
access at runtime. Too slow for me ATM. I hope we'll get a 5.2work3
soon.
> module 'upvals'
> local x,y = 10,20
> function one() return x end
> function two() return y end
>
> Say we want to recompile 'one' later so that it returns x+y; we have
> to look at the upvalues of all of the other module functions to find a
> reference - in this case y can be accessed through 'two'.
What about this?
function lexicalScopePlaceHolder()
 error("I'm not meant to be called")
 return x, y, z
end
-- Pierre-Yves

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