lua-users home
lua-l archive

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


On Tue, Dec 20, 2011 at 5:13 PM, Patrick Rapin <toupie300@gmail.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
backwards.

-- 
- Patrick Donnelly