lua-users home
lua-l archive

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


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