lua-users home
lua-l archive

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


On Thu, 11 Jun 2015 16:14:59 +0200
Dirk Laurie <...> wrote:
> 
> The rule is implementation-dependent, but the Lua implementation
> has not recently changed.
> 
> In the Lua 5.1 manual, the following boundary property was
> guaranteed:
> 
>     t[#t] is not nil, but t[#t+1] is.
> 
> This is no longer documented, perhaps because the user can now
> supply a __len that does not have that property.
> 

And there is such a case:
---------
Lua 5.3.0  Copyright (C) 1994-2015 Lua.org, PUC-Rio
> t = {nil, nil, 1, 2, nil, 4, nil, nil, 0, nil}
> =#t
0
> =t[#t]
nil
>
---------

> ...
>
> The difference you observe is caused by different sizes of the
> array part.
> 
> ...
 
Thank you for explanation, Dirk.

-- 
Mike