[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Detecting read or write access in __index metamethod
- From: Marc Balmer <marc@...>
- Date: Wed, 15 Dec 2010 16:33:17 +0100
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".