[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: length operator # for tables with metatables
- From: Roberto Ierusalimschy <roberto@...>
- Date: Tue, 22 Sep 2009 17:23:14 -0300
> Lua manual defines length operator "#" for tables as follows:
> [...]
>
> As one can see from the definition above tbl[#tbl+1] must always be nil.
>
> Unfortunately, it is not the case when table has a metatable as the
> following example illustrates:
>
> [...]
>
> Of course, I can always redefine __len meta-method to bring some
> sanity to the table. What worries me, though, is that the default
> behavior is so messy.
Probably the manual should mention that all operations in the
explanation refer to the raw operations, but most people somehow seem to
understand that.
> Am I missing something?
Goodwill?
-- Roberto