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

+1 vote
ago in Syntax and reader by
edited ago by
user=> (clojure.edn/read-string "777/2") ;; no surprises
777/2
user=> (clojure.edn/read-string "0777/2") ;; wait, 0777 supposed to be 511
777/2
user=> (clojure.edn/read-string "0x777/2") ;; hexadecimal suddenly throws
Execution error (NumberFormatException) at user/eval175 (REPL:1).
Invalid number: 0x777/2
user=> (clojure.edn/read-string "32r777/2") ;; radix throws as well
Execution error (NumberFormatException) at user/eval177 (REPL:1).
Invalid number: 32r777/2
user=> (clojure.edn/read-string "777N/2") ;; same for BigInt
Execution error (NumberFormatException) at user/eval181 (REPL:1).
Invalid number: 777N/2

Inconsistent part here is octal integer numerator form. I would expect it to fail the same way as the rest of this list but not to silently drop leading zero and turn to not octal form at all.

Second part of the question is: Why other forms throws at all?

Please log in or register to answer this question.

...