[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Bizarre behavior with debug.setupvalue() in Lua 5.3
- From: "Soni L." <fakedme@...>
- Date: Fri, 27 Mar 2015 23:17:43 -0300
On 27/03/15 11:06 PM, Sean Conner wrote:
You're changing the _value_ of the upvalue and expecting the _upvalue_
It was thus said that the Great Tim Hill once stated:
On Mar 27, 2015, at 2:28 PM, Sean Conner <firstname.lastname@example.org> wrote:
I would expect setting the first upvalue of meta.print() to meta would
make meta the default global environment for meta.print() and not replace
the current global environment.
Actually, the compiler makes no guarantees about which upvalue (if any)
for a function contains the _ENV environment EXCEPT in the case of the
implicit anonymous function that wraps a compiled chunk. The load() API
family always sets the first upvalue to the environment because it assumes
that the chunk being loaded was a compiled chunk (rather than an explicit
function within a chunk that was accessed with string.dump().
But that isn't the issue. Even if I got the wrong index, I did not expect
the global environment to change---only the environment for meta.print().
Disclaimer: these emails are public and can be accessed from <TODO: get a non-DHCP IP and put it here>. If you do not agree with this, DO NOT REPLY.