[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: New metamethod for method lookup
- From: Mark Hamburg <mark@...>
- Date: Sat, 21 Nov 2009 08:41:41 -0800
On Nov 17, 2009, at 7:20 PM, Mark Feldman wrote:
> This is not a contrived example, it's a direct analogy to OOP cases where grandparent is a base class, parent is a derived class and child is an instance of derived. Derived (parent) has to __index itself so that operators work properly on the instance, so the only way to efficiently implement virtual data members in this case is to change the VM so that either the value of self passed into settable remains constant as you traverse the metatable chain, or pass that value in as a third parameter into grandparent.__index. It's a negligable change to the VM that only effects __index function calls (which are slow anyway) but it would immediately add the ability to implement efficient virtual data members to inheritence heirarchies, which is a very useful feature of other OOP languages.
I've contemplated that change myself as well. It has the benefit of being entirely transparent to existing code.