lua-users home
lua-l archive

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


Axel Kittenberger <axkibe@gmail.com> writes:

>> It is not an "anti-value" but the default value.
>
> Not quite, as Wladimir showed nil is currnelty a bit more special than
> just a default value. A table.remove() might or might not stop on a
> nil value (internally if it is in the array part or the hash part).
>
> b = {}
> b[1] = 1
> b[2] = 2
> b[3] = 3
> b[6] = 6
> table.remove(b,1)
> for k,v in pairs(b) do print(k,v) end
> 1       2
> 2       3
> 6       6

That's just a consequence of # not being defined deterministically in
such cases.  So anything relying on a particular value of multiple
possible # is a programming error exhibiting undefined behavior due to
implementation details liable to change from one version to the next,
not a feature of the language.

-- 
David Kastrup