lua-users home
lua-l archive

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


On Fri, Apr 24, 2015 at 7:21 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> 2015-04-24 15:41 GMT+02:00 Egor Skriptunoff <egor.skriptunoff@gmail.com>:
>
>> Yes, we have strange results when sorting tables with NaNs inside.
>> But we don't have errors there.
>> Is it possible to receive "invalid order function for sorting" error for
>> default sorting (using default order function) of a table filled with mixed
>> integer/float values due to non-transitivity of default operator ">="?
>>
>> Transitivity of equality and relational operators sits very deep in our
>> brains.
>> A language without such transitivity would be counter-intuitive,
>> programming on it would be error-prone.
>>
>> IMHO, if both numbers are inside range 2^53...2^63, they should be compared
>> using conversion to integers, despite of possible performance penalty.
>
> Didn't Roberto say just that? Let me find it ...
>
> | (In terms of implementation, it means that integer-float should be
> | compared converting the float to an integer; if the conversion fails,
> | the numbers cannot be equal.) That definition is simple, sounds
> | sensible and easy to explain, and makes equality transitive.
>

That doesn't help with the issue of nontransitivity of >, only ==: if
the conversion fails, which number is "less"?

/s/ Adam