[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: multi-level inheritance and __index
- From: Dave Hayden <dave@...>
- Date: Wed, 14 Jan 2015 17:51:17 -0800
On Jan 14, 2015, at 3:20 PM, Steven Degutis <sbdegutis@gmail.com> wrote:
>
>> I want to synthesize properties on the base class using __index and __newindex so that they're available to all instances.
>
> To add methods to "all instances" of a class, you just add methods to
> the table that's the __index field on every instance's metatable, like
> so: [...]
Okay, but if I want to define an __index function to synthesize a property, I seem to be out of luck: The metatable is passed into __index(self, key), not the instance object.
Can someone verify that Lua just doesn't work that way?
-D