lua-users home
lua-l archive

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


On Wed, Dec 15, 2010 at 1:46 PM, joao lobato <btnfdp.lobato@gmail.com> wrote:
> While incurring the risk of being labeled flamebait, this is the kind
> of discussion around #t that I think makes sense.

It does make sense that __len is respected (less surprises for all)
but then to be consistent table.concat() should also respect
__tostring.  At the moment strings or numbers are fine.

The argument against this generalization is that making concat picky
catches stupid things early, rather than having to wade through
possibly large output results to find the duds.

It is consistent then to see the table.* functions as working only on
raw tables, and thus generally not respecting your attempts at
virtualisation.

Consider table.insert - even if your table has a __setindex to enforce
what goes into it, this function will ignore that. This is one big
difference between table.insert(t,val) and t[#t+1] = val. (This came
up when I was constructing a 'safe' array that could guarantee no
holes would be inserted..)

steve d.