Next: Escape Characters and Potential Numbers, Previous: Numbers as Tokens, Up: Numbers as Tokens
To allow implementors and future Common Lisp standards to extend the syntax of numbers, a syntax for potential numbers is defined that is more general than the syntax for numbers. A token is a potential number if it satisfies all of the following requirements:
[Reviewer Note by Barmar: This section is unnecessary because the first bullet already
omits discussion of a colon (package marker).]
but not a
package marker.
The syntax involving a leading
package marker followed by a potential number is
not well-defined. The consequences of the use
of notation such as :1, :1/2, and :2^3 in a
position where an expression appropriate for read
is expected are unspecified.
If a potential number has number syntax, a number of the appropriate type is constructed and returned, if the number is representable in an implementation. A number will not be representable in an implementation if it is outside the boundaries set by the implementation-dependent constants for numbers. For example, specifying too large or too small an exponent for a float may make the number impossible to represent in the implementation. A ratio with denominator zero (such as -35/000) is not represented in any implementation. When a token with the syntax of a number cannot be converted to an internal number, an error of type reader-error is signaled. An error must not be signaled for specifying too many significant digits for a float; a truncated or rounded value should be produced.
If there is an ambiguity as to whether a letter should be treated as a digit or as a number marker, the letter is treated as a digit.