lua-users home
lua-l archive

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


And we cant set the __len metamethod on a table to change this
behaviour. Bummer.

DB

On 3/6/06, Couwenberg, Wim <wim.couwenberg@oce.com> wrote:
> > it
> > would be convenient (and consistent) if the # operator
> > provided the following behaviour (this is the assertion):
> >
> > "# provides the same number as the number of iterations
> > provided by ipairs".
>
> Convenient maybe, but also more expensive.  The current # implementation
> is O(log(N)) where N is the number of entries in the array part.  The
> rule above would make that O(N) in general.  You can use table.maxn to
> find the highest overall numerical index (ignoring gaps).  This is of
> course also more expensive than applying #.
>
> --
> Wim
>
> This message and attachment(s) are intended solely for the use of the addressee and may contain information that is privileged, confidential or otherwise exempt from disclosure under applicable law.
> If you are not the intended recipient or agent thereof responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this communication is strictly prohibited.
> If you have received this communication in error, please notify the sender immediately by telephone and with a "reply" message.
> Thank you for your cooperation.
>
>
>