[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [proposal] Type metatables per environment
- From: Patrick Donnelly <batrick@...>
- Date: Wed, 21 Dec 2011 11:39:33 -0500
On Tue, Dec 20, 2011 at 5:13 PM, Patrick Rapin <email@example.com> wrote:
> My proposal is the following: provided it is possible, why not limit
> the metatable scope to the environment of the current function?
> Even better, I could imagine that the type metatables could be placed
> in the metatable of _ENV and manipulated from there.
This is a really cool idea. I would definitely like this feature.
The implementation difficulties seem problematic though. Lua has moved
away from the bytecode execution engine being aware of globals by
having _ENV as an upvalue: global accesses are indistinguishable from
upvalue accesses at the bytecode level. So, having the bytecode engine
needing to access _ENV as a typed-metamethod fallback would be a step
- Patrick Donnelly