s-expressionists / Eclector

A portable Common Lisp reader that is highly customizable, can recover from errors and can return concrete syntax trees
https://s-expressionists.github.io/Eclector/
BSD 2-Clause "Simplified" License
108 stars 9 forks source link

Read-from-string with *read-base* 4 inconsistent #39

Closed kpoeck closed 5 years ago

kpoeck commented 5 years ago

Consider: (newest eclector, current sbcl)

("eclector")
* (let ((*read-base* 4))
           (eclector.reader:read-from-string "2140.969"))
36.969
8
* (let ((*read-base* 4))(read-from-string "2140.969"))
2140.969
8
* (let ((*read-base* 4))
           (eclector.reader:read-from-string "2140"))
36
4

Seems that the digits before the dot are read with base 4, and the digits after the dot with base 10 (since they don't fit into base 4).

probabyly a problem for all read-base different from 10.

23.2.13 read-base says: The value of read-base, called the current input base, is the radix in which integers and ratios are to be read by the Lisp reader. The parsing of other numeric types (e.g., floats) is not affected by this option.

So I believe it is an error to apply read-base to floats at all