|
Mark Hamburg kirjoitti 20.3.2010 kello 19:27:
On Mar 20, 2010, at 1:54 AM, Asko Kauppi wrote:If you are interested in copying functions, the Lanes code can do that. It also copies upvalues.-askoDoes it also copy the environment? How does it decide where to stop? For example, if I stick math.sin into a local variable math_sin and reference this as an upvalue in the function I'm passing, what does it do?
I think it did not copy the environment, though that could actually be implemented if needed.
It would copy the function given as upvalue. It only stops when there's a recursion (i.e. it cannot copy a function which has itself as upvalue, though even this could possibly be implemented, if needed).
One reason I made it was to see just how far one can go with existing Lua API. Quite far, actually.
The responsibility of not overusing it (since any copying would naturally have a runtime penalty) is up to the application programmer.
Naturally, once the copying has been done the two upvalues in the two separate Lua states are completely detached. There is a separate concept of shared states for inter-state communications.
- Asko
Mark