Should this be correct behaviour?
Sean Kelly
sean at f4.ca
Fri Nov 30 06:24:53 PST 2007
Janice Caron wrote:
> On Nov 30, 2007 12:23 AM, Sean Kelly <sean at f4.ca> wrote:
>> If NaNs compared not equal via
>> TypeInfo comparisons
>
> They don't compare not equal even in normal use. They compare as being
> neither == nor !=.
>
> (I know you know that. Just trying to be precise here).
>
>> then any NaN used as an AA key would result in an
>> insertion that was lost forever. With this in mind, I think the current
>> behavior makes the most sense as well.
>
> There is another way of looking at it though. Using NaN as array key
> sounds like a bug to me. Should it even be permitted? Let's think this
> through - the interpretation of NaN here is either "unassigned
> variable", or "I don't know the answer" (for example, infinity divided
> by infinity). Is it even sensible to allow such a beast to be an array
> key?
Probably not. I guess the array code could test if the value being
inserted were equal to itself and if so, throw an exception? Seems a
bit of a corner case to test for explicitly though.
Sean
More information about the Digitalmars-d
mailing list