Kaz Kylheku <
221-50...@kylheku.com> wrote:
+---------------
| 2016-12-05, Rob Warnock <
rp...@rpw3.org> wrote:
| > Well, the CLHS doesn't define a type named FLOAT-DIGITS,
| > only a function of that name. So if the SBCL implementation
| > defines -- as an extension to the ANSI spec -- a type named
| > FLOAT-DIGITS, it seemed reasonable to me that it should match
| > the type of the result of the function FLOAT-DIGITS.
|
| Would it also seem reasonable if a type ATOM matched what
| is returned by the ATOM function?
+---------------
You have a point. ;-}
+---------------
| I'm not even sure that this is a conforming extension, if that
| FLOAT-DIGITS symbol being defined as a type name is in fact
| CL:FLOAT-DIGITS.
+---------------
At least in SBCL 1.3.1, it is in fact CL:FLOAT-DIGITS
[see last few lines]:
* (describe 'CL:FLOAT-DIGITS)
COMMON-LISP:FLOAT-DIGITS
[symbol]
FLOAT-DIGITS names a compiled function:
Lambda-list: (F)
Declared type: (FUNCTION (FLOAT) (VALUES (MOD 54) &OPTIONAL))
Derived type: (FUNCTION (T)
(VALUES (OR (INTEGER 24 24) (INTEGER 53 53))
&OPTIONAL))
Inline proclamation: INLINE (inline expansion available)
Known attributes: foldable, unsafely-flushable, movable
Source file: SYS:SRC;CODE;FLOAT.LISP
FLOAT-DIGITS names a type-specifier:
Lambda-list: ()
Expansion: (INTEGER 0 53)
*
FWIW, SBCL also defines/exports a number of non-standard
related constant variables that seem like they should be
more useful than that questionable type specifier:
* (list SB-VM:SINGLE-FLOAT-DIGITS
SB-VM:DOUBLE-FLOAT-DIGITS
SB-VM:LONG-FLOAT-DIGITS)
(24 53 64)
*
Though those constants should be discoverable in a standard,
portable way:
* (mapcar #'float-digits (list most-positive-short-float
most-positive-single-float
most-positive-double-float
most-positive-long-float))
(24 24 53 53)
*
or, equivalently:
* (mapcar #'float-digits (list 1.0s0 1.0f0 1.0d0 1.0l0))
(24 24 53 53)
*
Unfortunately, these portable results are inconsistent
with that SB-VM:LONG-FLOAT-DIGITS symbol, leading one
to wonder which is correct. Hmmm...
* 1.0l0
1.0d0
*
Longs are actually doubles here, so the portable version is correct.