lua-users home
lua-l archive

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

On Jan 14, 2015, at 3:20 PM, Steven Degutis <> 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?