[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: In praise of 'nil' (Was: Proposal for table length operator
- From: David Kastrup <dak@...>
- Date: Wed, 15 Dec 2010 10:59:45 +0100
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
- References:
- Re: Proposal for table length operator, Gunnar Zötl
- Re: Proposal for table length operator, Mark Hamburg
- Re: Proposal for table length operator, Roberto Ierusalimschy
- Re: Proposal for table length operator, Mark Hamburg
- In praise of 'nil' (Was: Proposal for table length operator, Dirk Laurie
- Re: In praise of 'nil' (Was: Proposal for table length operator, Axel Kittenberger
- Re: In praise of 'nil' (Was: Proposal for table length operator, Dirk Laurie
- Re: In praise of 'nil' (Was: Proposal for table length operator, Pierre-Yves Gérardy
- Re: In praise of 'nil' (Was: Proposal for table length operator, steve donovan
- Re: In praise of 'nil' (Was: Proposal for table length operator, David Kastrup
- Re: In praise of 'nil' (Was: Proposal for table length operator, Axel Kittenberger