Discussion:
what are these types?
Jim Newton
2020-03-13 18:19:19 UTC
Can someone help me understand what these types are?

(OR (REAL * (-3.5d0)) (REAL (-3.5d0))

Is that all the real numbers except -3.5d0

(OR (REAL * (-3.5d0))
(REAL (-3.5d0))
(NOT INTEGER))
Alan Bawden
2020-03-13 18:44:03 UTC
Post by Jim Newton
Can someone help me understand what these types are?
(OR (REAL * (-3.5d0))
(REAL (-3.5d0)))
Is that all the real numbers except -3.5d0
Yes. (Assuming that the extra ")" I added went where you expected it.)
Note that this type contains _all_ objects of type INTEGER.
Post by Jim Newton
(OR (REAL * (-3.5d0))
(REAL (-3.5d0))
(NOT INTEGER))
Now you've added the non-integers, so this type is true of everything. It
is equivalent to the type T. (Except your implementation may not be able
to recognize that.)
--
Alan Bawden
Stefan Monnier
2020-03-16 15:36:43 UTC
Post by Jim Newton
Can someone help me understand what these types are?
(OR (REAL * (-3.5d0))
(REAL (-3.5d0)))
Is that all the real numbers except -3.5d0
Does include -3.5e0? -7/2?
(i.e. does it assume an equality for type membership based on `=` or on `eql`?)

Stefan
Alan Bawden
2020-03-16 20:04:50 UTC
Post by Stefan Monnier
Post by Jim Newton
Can someone help me understand what these types are?
(OR (REAL * (-3.5d0))
(REAL (-3.5d0)))
Is that all the real numbers except -3.5d0
Does include -3.5e0? -7/2?
(i.e. does it assume an equality for type membership based on `=` or on `eql`?)
The type (REAL (-3.5d0)) might be defined by the predicate:

(defun test (x)
(and (realp x)
(> x -3.5d0)))

No `=' or `eql' needed.
--
Alan Bawden
Stefan Monnier
2020-03-16 20:20:11 UTC
Post by Alan Bawden
Post by Stefan Monnier
Post by Jim Newton
Can someone help me understand what these types are?
(OR (REAL * (-3.5d0))
(REAL (-3.5d0)))
Is that all the real numbers except -3.5d0
Does include -3.5e0? -7/2?
(i.e. does it assume an equality for type membership based on `=` or on `eql`?)
(defun test (x)
(and (realp x)
(> x -3.5d0)))
No `=' or `eql' needed.
But it ends up being more like =` than `eql` (i.e. it also
excludes -3.5e0 and -7/2).

Stefan
smh
2020-03-18 00:03:37 UTC
Post by Stefan Monnier
But it ends up being more like =` than `eql` (i.e. it also
excludes -3.5e0 and -7/2).
Putting on my grandest language lawyer hat (the one with the tallest feathers sticking out of the crown) I'll point out this isn't _necessarily_ true.

The ANS description of FLOAT (see the dictionary entry in chapter 12) doesn't restrict the value of the float base _b_ (aka the radix), and in an implementation with radix a prime other than 2 there will be no float value that is exactly equal to -7/2. So the float approximation might be slightly greater or less than -7/2.

Of course, every known implementation uses IEEE in which the float radix is 2, so this problem is theoretical only.
Stefan Monnier
2020-03-18 17:25:44 UTC