On Friday, March 16, 2018 at 10:18:10 AM UTC-7, sds wrote:
> > * Jim Newton <wvzxn...@tznvy.pbz> [2018-03-16 07:52:11 -0700]:
> >
> > Can anyone explain to me what (subtypep '(float 0.0 0.0) '(eql 0.0))
> > should evaluate to?
> > In SBCL it evaluates to NIL,T which seems bizarre to me.
>
> Seems legit, you are forgetting that (eql 0.0 0.0s0) is NIL:
That depends on what the default float type is.
In my SBCL (eql 0.0 0.0s0) => T whereas (eql 0.0 0.0d0) => NIL.
>
> --8<---------------cut here---------------start------------->8---
> [1]> (subtypep '(float 0.0 0.0) '(eql 0.0))
> NIL ;
> T
> [2]> (typep 0.0s0 '(float 0.0 0.0))
> T
But also
(typep 0.0d0 '(float 0.0 0.0)) => T
(typep 0.0s0 '(float 0.0d0 0.0d0)) => T as well
> [3]> (typep 0.0s0 '(eql 0.0))
Depends on the setting of *READ-DEFAULT-FLOAT-FORMAT* and how many types of
floats are supported in your lisp implementation.
> NIL
> --8<---------------cut here---------------end--------------->8---
The EQL type descriptor is narrower since it requires type equivalence, which will make it potentially implementation-dependent. And since the FLOAT type
specifier will do type conversions, it is a supertype:
(subtypep '(eql 0.0) '(float 0.0 0.0)) => T T