[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: __index and __newindex
- From: Marc Balmer <marc@...>
- Date: Wed, 27 Apr 2011 09:26:50 +0200
Am 27.04.11 09:23, schrieb Alexander Gladysh:
> On Wed, Apr 27, 2011 at 10:58, Marc Balmer <marc@msys.ch> wrote:
>
>>> I often see that people do miss the fact that __index and __newindex
>>> are called for non-existant keys only. When I was a newbie I missed
>>> that too.
>
>> To be correct, this is only the case for tables.
>
> For the tables, that's right. But what is exactly 'non-existant key'
> in userdata? ;-)
userdata can mimick the behaviour of tables.
>
>>> Maybe it is a good idea to emphasize this fact in the manual? Like add
>>> a short sentence to the blob of code that now describes the metamethod
>>> behaviour.
>
>> The pseudo code in the reference manual describes this very cleary, imo.
>
> I do not argue with that.
>
>>> I would even go further and add a full natural language description to
>>> each metamethod. While a blob of code is sufficient, it is too formal
>>> for newbie (who is not necessarily verse enough in Lua to get a full
>>> grasp of it).
>
>> A blob of code is what programmers should be able to read, imo.
>
> Nevertheless, it is clearly not enough.
To be honestm I also made that mistake. But then I reread the Blob and
saw why my initial program failed. I still find it is enough, but I
would certainly not object if it was described more verbose.