1
0
Fork 0
cl-sites/HyperSpec-7-0/HyperSpec/Body/02_caa.htm
2024-04-01 10:24:07 +02:00

41 lines
6.6 KiB
HTML

<!-- Common Lisp HyperSpec (TM), version 7.0 generated by Kent M. Pitman on Mon, 11-Apr-2005 2:31am EDT -->
<HTML>
<HEAD>
<TITLE>CLHS: Section 2.3.1.1</TITLE>
<LINK HREF="../Data/clhs.css" REL="stylesheet" TYPE="text/css" />
<META HTTP-EQUIV="Author" CONTENT="Kent M. Pitman">
<META HTTP-EQUIV="Organization" CONTENT="LispWorks Ltd.">
<LINK REL=TOP HREF="../Front/index.htm">
<LINK REL=COPYRIGHT HREF="../Front/Help.htm#Legal">
<LINK REL=DISCLAIMER HREF="../Front/Help.htm#Disclaimer">
<LINK REL=PREV HREF="02_ca.htm">
<LINK REL=UP HREF="02_ca.htm">
<LINK REL=NEXT HREF="02_caaa.htm">
</HEAD>
<BODY>
<H1><A REV=MADE HREF="http://www.lispworks.com/"><IMG WIDTH=80 HEIGHT=65 ALT="[LISPWORKS]" SRC="../Graphics/LWSmall.gif" ALIGN=Bottom></A><A REL=TOP HREF="../Front/index.htm"><IMG WIDTH=237 HEIGHT=65 ALT="[Common Lisp HyperSpec (TM)]" SRC="../Graphics/CLHS_Sm.gif" ALIGN=Bottom></A> <A REL=PREV HREF="02_ca.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="02_ca.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="02_caaa.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>
2.3.1.1 Potential Numbers as Tokens</H2> <P>
To allow implementors and future Common Lisp standards to extend the syntax of numbers, a syntax for <A REL=DEFINITION HREF="26_glo_p.htm#potential_number"><I>potential numbers</I></A> is defined that is more general than the syntax for numbers. A <A REL=DEFINITION HREF="26_glo_t.htm#token"><I>token</I></A> is a <A REL=DEFINITION HREF="26_glo_p.htm#potential_number"><I>potential number</I></A> if it satisfies all of the following requirements: <P>
<P><DL><DT>1. The <A REL=DEFINITION HREF="26_glo_t.htm#token"><I>token</I></A> consists entirely of <A REL=DEFINITION HREF="26_glo_d.htm#digit"><I>digits</I></A>, <A REL=DEFINITION HREF="26_glo_s.htm#sign"><I>signs</I></A>, <A REL=DEFINITION HREF="26_glo_r.htm#ratio_marker"><I>ratio markers</I></A>, decimal points (<TT>.</TT>), extension characters (^ or <TT>_</TT>), and number markers. A number marker is a letter. Whether a letter may be treated as a number marker depends on context, but no letter that is adjacent to another letter may ever be treated as a number marker. <A REL=DEFINITION HREF="26_glo_e.htm#exponent_marker"><I>Exponent markers</I></A> are number markers. <P><DD>
<DT>2. The <A REL=DEFINITION HREF="26_glo_t.htm#token"><I>token</I></A> contains at least one digit. Letters may be considered to be digits, depending on the <A REL=DEFINITION HREF="26_glo_c.htm#current_input_base"><I>current input base</I></A>, but only in <A REL=DEFINITION HREF="26_glo_t.htm#token"><I>tokens</I></A> containing no decimal points. <P><DD>
<DT>3. The <A REL=DEFINITION HREF="26_glo_t.htm#token"><I>token</I></A> begins with a <A REL=DEFINITION HREF="26_glo_d.htm#digit"><I>digit</I></A>, <A REL=DEFINITION HREF="26_glo_s.htm#sign"><I>sign</I></A>, decimal point, or extension character, but not a <A REL=DEFINITION HREF="26_glo_p.htm#package_marker"><I>package marker</I></A>. The syntax involving a leading <A REL=DEFINITION HREF="26_glo_p.htm#package_marker"><I>package marker</I></A> followed by a <A REL=DEFINITION HREF="26_glo_p.htm#potential_number"><I>potential number</I></A> is not well-defined. The consequences of the use of notation such as <TT>:1</TT>, <TT>:1/2</TT>, and <TT>:2^3</TT> in a position where an expression appropriate for <A REL=DEFINITION HREF="f_rd_rd.htm#read"><B>read</B></A> is expected are unspecified. <P><DD>
<DT>4. The <A REL=DEFINITION HREF="26_glo_t.htm#token"><I>token</I></A> does not end with a sign. <P><DD></DL><P>
If a <A REL=DEFINITION HREF="26_glo_p.htm#potential_number"><I>potential number</I></A> has number syntax, a <A REL=DEFINITION HREF="26_glo_n.htm#number"><I>number</I></A> of the appropriate type is constructed and returned, if the <A REL=DEFINITION HREF="26_glo_n.htm#number"><I>number</I></A> is representable in an implementation. A <A REL=DEFINITION HREF="26_glo_n.htm#number"><I>number</I></A> will not be representable in an implementation if it is outside the boundaries set by the <A REL=DEFINITION HREF="26_glo_i.htm#implementation-dependent"><I>implementation-dependent</I></A> constants for <A REL=DEFINITION HREF="26_glo_n.htm#number"><I>numbers</I></A>. For example, specifying too large or too small an exponent for a <A REL=DEFINITION HREF="26_glo_f.htm#float"><I>float</I></A> may make the <A REL=DEFINITION HREF="26_glo_n.htm#number"><I>number</I></A> impossible to represent in the implementation. A <A REL=DEFINITION HREF="26_glo_r.htm#ratio"><I>ratio</I></A> with denominator zero (such as <TT>-35/000</TT>) is not represented in any implementation. When a <A REL=DEFINITION HREF="26_glo_t.htm#token"><I>token</I></A> with the syntax of a number cannot be converted to an internal <A REL=DEFINITION HREF="26_glo_n.htm#number"><I>number</I></A>, an error of <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> <A REL=DEFINITION HREF="e_rder_e.htm#reader-error"><B>reader-error</B></A> is signaled. An error must not be signaled for specifying too many significant digits for a <A REL=DEFINITION HREF="26_glo_f.htm#float"><I>float</I></A>; a truncated or rounded value should be produced. <P>
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. <P>
<A REL=CHILD HREF="02_caaa.htm"><H2>
2.3.1.1.1 Escape Characters and Potential Numbers</H2></A><P>
<A REL=CHILD HREF="02_caab.htm"><H2>
2.3.1.1.2 Examples of Potential Numbers</H2></A><P><P><HR>The following <A REL=META HREF="../Front/X3J13Iss.htm">X3J13 cleanup issue</A>, <I>not part of the specification</I>, applies to this section:<P><UL><LI> <A REL=CHILD HREF="../Issues/iss055.htm">COLON-NUMBER</A><P></UL><HR>
<A REL=NAVIGATOR HREF="../Front/StartPts.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Starting Points]" SRC="../Graphics/StartPts.gif" ALIGN=Bottom></A><A REL=TOC HREF="../Front/Contents.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Contents]" SRC="../Graphics/Contents.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Master.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Index]" SRC="../Graphics/Index.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Symbol.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Symbols]" SRC="../Graphics/Symbols.gif" ALIGN=Bottom></A><A REL=GLOSSARY HREF="../Body/26_a.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Glossary]" SRC="../Graphics/Glossary.gif" ALIGN=Bottom></A><A HREF="../Front/X3J13Iss.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Issues]" SRC="../Graphics/Issues.gif" ALIGN=Bottom></A><BR>
<A REL=COPYRIGHT HREF="../Front/Help.htm#Legal"><I>Copyright 1996-2005, LispWorks Ltd. All rights reserved.</I></A><P>
</BODY>
</HTML>