[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Emacs-diffs] master 37940b3: min and max now return one of their ar
From: |
Paul Eggert |
Subject: |
Re: [Emacs-diffs] master 37940b3: min and max now return one of their arguments |
Date: |
Wed, 8 Mar 2017 14:04:54 -0800 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 |
On 03/08/2017 07:54 AM, Eli Zaretskii wrote:
Don't programmers
assume in general that comparisons between values some of which are
floats are always done after converting_all_ values to the
floating-point representation?
No, and that hasn't been true for Emacs Lisp for quite some time. In
Emacs 25, (<= 10000000000000001 10000000000000000 1e16) returns the
mathematically-correct answer nil on a 64-bit GNU/Linux host even though
it would return t if all values were first converted to float.
More generally, although people expect statically typed languages to
convert alternatives to float (e.g., C programmers expect (1.5 > 2 ? 1.5
: 2) to return 2.0 not 2), dynamically typed languages are different:
Lisp programmers expect (if (> 1.5 2) 1.5 2) to return 2 not 2.0.
Admittedly the situation with min and max is not quite as simple as with
'if' (which clearly should not convert). Still, it's verrrry strange for
(< A (min A B)) to return t, and having 'min' return the numerically
correct answer avoids nonsensical behavior like that.
I find the commentary in 'arithcompare' not detailed enough
I installed the attached, which I hope helps.
0001-src-data.c-arithcompare-Add-comments.patch
Description: Source code patch