lua-users home
lua-l archive

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



Yeah, also it is wise not to have too known-to-be-slow features around, unless they're named like maxn_crawl() ;) which.. please don't use! :D

I agree with you, that maxn() wouldn't be missed.

-asko


Mike Pall kirjoitti 18.1.2006 kello 18.52:

Hi,

Asko Kauppi wrote:
1. Is #t NOT expected to work, if a table has both integer (1..N) and
other (string, etc) keys?

Sorry, my wording was too ambiguous.

Of course #t always 'works' in the sense that it finds the
maximum positive integral key for arrays without holes. It
doesn't matter if there are other keys, too:

 print(#{ 0, [1.5]=0, 0, [2.5]=0, foo=0 }) --> 2

My point was that newbies could easily be lead to the wrong
conclusion that table.maxn is the standard way to get the length
of a table. But it's only a fallback for exceptional cases.

Bye,
     Mike