[Armedbear-devel] more EQUALP woes (patch attached)

Massimiliano Ghilardi massimiliano.ghilardi+abcl at gmail.com
Tue Mar 3 21:13:17 UTC 2015


Hello,

my previous patch fixed some cases where EQUALP signaled errors, but was 
not a full solution.
In attachment you can find a second patch, to be applied on top of the 
first one, to fix the remaining EQUALP issues.

It solves the problems shown by the following test:

(loop for x in (list most-positive-single-float
                      most-positive-double-float)
    do
      (loop for y in (list (1- (ash #xFFFFFF 104))
                           (ash #xFFFFFF 104)
                           (1- (ash #xFFFFFFFFFFFFF8 968))
                           (ash #xFFFFFFFFFFFFF8 968)
                           (ash 1 1024)
                           (/ (ash 1 1026) 3))
         do
           (handler-case
               (format t "~S ~S ~S ~S~%"
                  (= x y) (= x y) (equalp x y) (equalp y x))
             (condition (c) (format t "error: ~A~%" c)))))

On SBCL and CLISP, this test correctly prints (due to 32-bit IEEE 
single-floats and 64-bit IEEE double-floats) :
----------------------------------------------------------
NIL NIL NIL NIL
T T T T
NIL NIL NIL NIL
NIL NIL NIL NIL
NIL NIL NIL NIL
NIL NIL NIL NIL
NIL NIL NIL NIL
NIL NIL NIL NIL
NIL NIL NIL NIL
T T T T
NIL NIL NIL NIL
NIL NIL NIL NIL
----------------------------------------------------------


After applying my first patch, ABCL 1.3.1 prints:
----------------------------------------------------------
NIL NIL T T ;; note: EQUALP and = disagree
T T T T
error: The value 1797... is too large to be converted to a single float.
error: The value 1797... is too large to be converted to a single float.
error: The value 1797... is too large to be converted to a single float.
error: The value 7190.../3 is not of type DOUBLE-FLOAT.
NIL NIL NIL NIL
NIL NIL NIL NIL
NIL NIL T T ;; note: EQUALP and = disagree again
T T T T
error: The value 1797... is too large to be converted to a double float.
error: The value 7190.../3 is not of type DOUBLE-FLOAT.
----------------------------------------------------------

that is quite clearly bugged, since CLHS states:
1) for numbers, EQUALP is the same as =
2) EQUALP must never signal errors

(without my first patch, the outcome is worse).

With the second patch in attachment, this test succeeds on ABCL too.

I hope you will appreciate the irony that I *removed* code instead of 
adding it...


Regards,

Massimiliano Ghilardi

-------------- next part --------------
A non-text attachment was scrubbed...
Name: abcl-14749-equalp-fix-2.diff
Type: text/x-patch
Size: 5810 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/armedbear-devel/attachments/20150303/94769ad4/attachment.bin>
-------------- next part --------------
_______________________________________________
Armedbear-devel mailing list
Armedbear-devel at common-lisp.net
https://mailman.common-lisp.net/cgi-bin/mailman/listinfo/armedbear-devel


More information about the armedbear-devel mailing list