lua-users home
lua-l archive

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


2016-07-07 18:15 GMT+02:00 Joseph Manning <manning@cs.ucc.ie>:
> On 2016-Jul-07 (Thu) at 09:08 (+0200), steve donovan wrote:
>
>>> It would be cool if #t was O(1), however.
>
> Steve,
>
>    In theory, yes indeed, this would be nice and neat and clean.
>
>    In practice, however, computing #t is blazingly fast.

The problem that people have with # is not its speed, it is
the non-determinism. I.e. fixed size is conceptually easy,
the first frontier is easy, the largest numeric index is easy,
but some unpredicatable unspecified frontier is sophisticated.

The current equivocation, that # is undefined when the table
is not a sequence, sells it short. The property documented
in the Lua 5.1 manual, that t[#t+1] is guaranteed to be an
empty slot, is a useful one, no matter how many newbies
are puzzled by it.