Non-numeric characters clarification

3 views
Skip to first unread message

Abhishek Reddy

unread,
Dec 24, 2008, 7:23:26 PM12/24/08
to clo...@googlegroups.com
Hi,

http://clojure.org/reader says symbols "begin with a non-numeric
character and can contain alphanumeric characters and *, + ..."

What are the numeric characters? It seems to include '+' and '-' as
well as digits -- is that correct, and are there any more?

Cheers

--
Abhishek Reddy
http://abhishek.geek.nz

Stephen C. Gilardi

unread,
Dec 24, 2008, 8:15:20 PM12/24/08
to clo...@googlegroups.com
Numeric characters are the digits 0 through 9. Are you seeing some
behavior that suggests otherwise?

Symbols can begin with + or - .

--Steve

Randall R Schulz

unread,
Dec 24, 2008, 8:34:47 PM12/24/08
to clo...@googlegroups.com
On Wednesday 24 December 2008 16:23, Abhishek Reddy wrote:
> Hi,
>
> http://clojure.org/reader says symbols "begin with a non-numeric
> character and can contain alphanumeric characters and *, + ..."
>
> What are the numeric characters? It seems to include '+' and '-' as
> well as digits -- is that correct, and are there any more?
>
> Cheers

For something as simple as this (as well as things far more complex), it
never hurts to include a few examples (transcripts of Clojure REPL
interactions) that illustrate you issue.

Anyway, it seems that if a token begins with '+' or '-' and is
immediately followed by a digit or a decimal point, then the parser is
committed to decoding a number and if the sequence of characters so
beginning and continuing through until a white-space character
(including ',') cannot be validly construed as or decoded to a number,
then some sort of failure results.

The only possible anomaly I've been able to detect is this:

user=> +.0
java.lang.ClassNotFoundException: +.0

As far as I can tell, any input subsequence (either initial or following
a white-space or comma separator) that begins with '+' or '-' and whose
next character is a decimal point will yield this error. A sequence
beginning with '+' or '-' and followed by a (non-white-space) character
that is not a digit and not a decimal point will be decoded as a
symbol.

Considering the particular error elicited, I suspect some sort of bug.
At a minimum, it seems a "sub-optimal" indication of an unacceptable
input sequence.


Randall Schulz

Abhishek Reddy

unread,
Dec 24, 2008, 8:36:10 PM12/24/08
to clo...@googlegroups.com
This is what I'm seeing in Clojure rev 1185:

user=> '+x
+x
user=> '+5x
java.lang.NumberFormatException: Invalid number: +5x

Cheers
Reply all
Reply to author
Forward
0 new messages