[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Bizarre behavior with debug.setupvalue() in Lua 5.3
- From: Sean Conner <sean@...>
- Date: Fri, 27 Mar 2015 22:06:27 -0400
It was thus said that the Great Tim Hill once stated:
>
> > On Mar 27, 2015, at 2:28 PM, Sean Conner <sean@conman.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().
-spc