## clisp-list

 [clisp-list] Some digit-chars don't read as numbers! From: Pascal J.Bourguignon - 2005-05-14 11:56:16 ```[384]> (digit-char-p #\５) ; == #\FULLWIDTH_DIGIT_FIVE 5 [385]> (digit-char-p #\１) ; == #\FULLWIDTH_DIGIT_ONE 1 [386]> ５／１５ *** - EVAL: variable ５／１５ has no value [389]> ５ *** - EVAL: variable ５ has no value While the standard doesn't specify clearly anything about non standard characters, it seems to me that if (digit-char-p #\５) is true, then ５ should read as the integer 5, and ５／１５ should read as the ratio 1/3. The same for all the other digit-chars in the charsets... Extracts from CLHS: ---------------------------------------- 2.3.1 Numbers as Tokens When a token is read, it is interpreted as a number or symbol. The token is interpreted as a number if it satisfies the syntax for numbers specified in the next figure. numeric-token ::= integer | ratio | float integer ::= [sign] decimal-digit+ decimal-point | [sign] digit+ ratio ::= [sign] {digit}+ slash {digit}+ float ::= [sign] {decimal-digit}* decimal-point {decimal-digit}+ [exponent] | [sign] {decimal-digit}+ [decimal-point {decimal-digit}*] exponent exponent ::= exponent-marker [sign] {digit}+ sign---a sign. slash---a slash decimal-point---a dot. exponent-marker---an exponent marker. decimal-digit---a digit in radix 10. digit---a digit in the current input radix. Figure 2-9. Syntax for Numeric Tokens ---------------------------------------- digit n. (in a radix) a character that is among the possible digits (0 to 9, A to Z, and a to z) and that is defined to have an associated numeric weight as a digit in that radix. See Section 13.1.4.6 (Digits in a Radix). ---------------------------------------- 13.1.4.4 Numeric Characters The numeric characters are a subset of the graphic characters. Of the standard characters, only these are numeric characters: 0 1 2 3 4 5 6 7 8 9 For each implementation-defined graphic character that has no case, the implementation must define whether or not it is a numeric character. ---------------------------------------- 13.1.4.6 Digits in a Radix What qualifies as a digit depends on the radix (an integer between 2 and 36, inclusive). The potential digits are: 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Their respective weights are 0, 1, 2, ... 35. In any given radix n, only the first n potential digits are considered to be digits. For example, the digits in radix 2 are 0 and 1, the digits in radix 10 are 0 through 9, and the digits in radix 16 are 0 through F. Case is not significant in digits; for example, in radix 16, both F and f are digits with weight 15. ---------------------------------------- Function DIGIT-CHAR-P Syntax: digit-char-p char &optional radix => weight Arguments and Values: char---a character. radix---a radix. The default is 10. weight---either a non-negative integer less than radix, or false. Description: Tests whether char is a digit in the specified radix (i.e., with a weight less than radix). If it is a digit in that radix, its weight is returned as an integer; otherwise nil is returned. ---------------------------------------- -- __Pascal Bourguignon__ http://www.informatimago.com/ Nobody can fix the economy. Nobody can be trusted with their finger on the button. Nobody's perfect. VOTE FOR NOBODY. ```
 [clisp-list] Re: Some digit-chars don't read as numbers! From: Sam Steingold - 2005-05-14 18:43:58 ```this is an interesting question. why don't you raise it on c.l.l? > * Pascal J.Bourguignon [2005-05-14 13:55:58 +0200= ]: > > [384]> (digit-char-p #\=EF=BC=95) ; =3D=3D #\FULLWIDTH_DIGIT_FIVE > 5 > [385]> (digit-char-p #\=EF=BC=91) ; =3D=3D #\FULLWIDTH_DIGIT_ONE > 1 > [386]> =EF=BC=95=EF=BC=8F=EF=BC=91=EF=BC=95 > > *** - EVAL: variable =EF=BC=95=EF=BC=8F=EF=BC=91=EF=BC=95 has no value > > [389]> =EF=BC=95 > > *** - EVAL: variable =EF=BC=95 has no value > > > While the standard doesn't specify clearly anything about non standard > characters, it seems to me that if (digit-char-p #\=EF=BC=95) is true, th= en =EF=BC=95 > should read as the integer 5, and =EF=BC=95=EF=BC=8F=EF=BC=91=EF=BC=95 sh= ould read as the ratio > 1/3. The same for all the other digit-chars in the charsets... > > > > Extracts from CLHS: > ---------------------------------------- > > 2.3.1 Numbers as Tokens > > When a token is read, it is interpreted as a number or symbol. The > token is interpreted as a number if it satisfies the syntax for > numbers specified in the next figure. > > numeric-token ::=3D integer | > ratio | > float=20=20=20=20=20=20=20 > integer ::=3D [sign] > decimal-digit+ > decimal-point | > [sign] > digit+=20=20=20=20=20=20 > ratio ::=3D [sign] > {digit}+ > slash > {digit}+=20=20=20=20 > float ::=3D [sign] > {decimal-digit}* > decimal-point > {decimal-digit}+ > [exponent]=20=20 > |=20 > [sign] > {decimal-digit}+ > [decimal-point > {decimal-digit}*] > exponent=20=20=20=20 > exponent ::=3D exponent-marker > [sign] > {digit}+=20=20=20=20 >=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 > sign---a sign.=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20 > slash---a slash=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20 > decimal-point---a dot.=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20 > exponent-marker---an exponent marker.=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20 > decimal-digit---a digit in radix 10.=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20 > digit---a digit in the current input radix.=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20 > > Figure 2-9. Syntax for Numeric Tokens > > ---------------------------------------- > > digit n. (in a radix) a character that is among the possible digits (0 > to 9, A to Z, and a to z) and that is defined to have an associated > numeric weight as a digit in that radix. See Section 13.1.4.6 (Digits > in a Radix). > > ---------------------------------------- > > 13.1.4.4 Numeric Characters > > The numeric characters are a subset of the graphic characters. Of the > standard characters, only these are numeric characters: > > 0 1 2 3 4 5 6 7 8 9 > > For each implementation-defined graphic character that has no case, > the implementation must define whether or not it is a numeric > character.=20 > > ---------------------------------------- > > 13.1.4.6 Digits in a Radix > > What qualifies as a digit depends on the radix (an integer between 2 > and 36, inclusive). The potential digits are: > > 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z > > Their respective weights are 0, 1, 2, ... 35. In any given radix n, > only the first n potential digits are considered to be digits. For > example, the digits in radix 2 are 0 and 1, the digits in radix 10 are > 0 through 9, and the digits in radix 16 are 0 through F. > > Case is not significant in digits; for example, in radix 16, both F > and f are digits with weight 15.=20 > > ---------------------------------------- > > Function DIGIT-CHAR-P > > Syntax: > > digit-char-p char &optional radix =3D> weight > > Arguments and Values: > > char---a character. > > radix---a radix. The default is 10. > > weight---either a non-negative integer less than radix, or false. > > Description: > > Tests whether char is a digit in the specified radix (i.e., with a > weight less than radix). If it is a digit in that radix, its weight is > returned as an integer; otherwise nil is returned.=20 > > ---------------------------------------- > > > --=20 > __Pascal Bourguignon__ http://www.informatimago.com/ > > Nobody can fix the economy. Nobody can be trusted with their finger > on the button. Nobody's perfect. VOTE FOR NOBODY. > > > ------------------------------------------------------- > This SF.Net email is sponsored by Oracle Space Sweepstakes > Want to be the first software developer in space? > Enter now for the Oracle Space Sweepstakes! > http://ads.osdn.com/?ad_id=3D7393&alloc_id=3D16281&op=3Dclick --=20 Sam Steingold (http://www.podval.org/~sds) running w2k ; ; ; ; ; Trespassers will be shot. Survivors will be prosecuted. ```