lua-users home
lua-l archive

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


Am 15.12.10 16:30, schrieb HyperHacker:
> On Wed, Dec 15, 2010 at 08:28, Marc Balmer <marc@msys.ch> wrote:
>> Is there a way to detect in an __index meta-method, written in C, if the
>> access is for reading or writing a value?  I.e. to distinguish between
>>
>> a.b.c = 42
>>
>> and
>>
>> local answer = a.b.c
>>
>> ?
>>
>> - mb
>>
>>
> 
> The first triggers __newindex, if the value isn't already set.

Yes, but only for tables.  I am "hiding" a hierarchical data container
behind this syntax, so my data is actually "userdata".