Welcome! Please see the About page for a little more info on how this works.

0 votes
in Docs by

The data structures section on numbers (https://clojure.org/reference/data_structures#Numbers) doesn't mention any of the alternate radix numbers. Reading the code in LispReader is challenging, I'm not exactly sure how it should work. Is there another place this is documented? If not, can the various ways be documented?

Here's what I've discovered from reading the regex and code, not sure which of this is intentional or undefined behavior:

0      ; 0
+0     ; 0
+0N    ; 0N
1      ; 1
-1     ; -1
123    ; 123
123N   ; 123N
0x1A   ; 26
0x1AN  ; 26N
012    ; 10
012N   ; 10N
12r1   ; 1
12r1N  ; fails
12r2a  ; 34
12r2aN ; fails

1 Answer

+1 vote
by
selected by
 
Best answer

There are some docs on the reader page under https://clojure.org/reference/reader#_literals

Those examples all look right to me.

by
Thanks, I didn't think to read that page. Would you be interested in either having a dedicated Numbers or Literals page or linking from Data structures to this so folks don't read the reader page can still find the relevant information? In my opinion, "Reader" feels like implementation or low-level details, not definitions of data types.
by
In this case, the syntax is about reading numbers in your code. Once they are read, they are just longs or whatever, so this is really a syntax thing and that's what is defined on the Reader page.
by
Alright, thanks.
Welcome to Clojure Q&A, where you can ask questions and receive answers from members of the Clojure community.
...