clasp icon indicating copy to clipboard operation
clasp copied to clipboard

Adding a character macro on digits breaks #x

Open stassats opened this issue 9 months ago • 2 comments

(let ((*readtable* (copy-readtable)))
  (set-macro-character #\1 (lambda (s char) 1) t) ;; just imagine a more complete reader
  (read-from-string "#x1"))

Eclector says "The character 1 is not a digit in base 16." because its eclector.readtable:syntax-type is not :constituent.

I can't say what the standard wants, but all other lisp are okay with that.

stassats avatar Mar 10 '25 17:03 stassats

There's only one sentence to apply for this The consequences are undefined if the token immediately following the #nR does not have the syntax of a rational in radix n.

But then #x+10 => The character + is not a digit in base 16.

Or #10r10. => The character . is not a digit in base 10.

stassats avatar Mar 10 '25 17:03 stassats

The reader macro problem from the first comment has been fixed in https://github.com/s-expressionists/Eclector/commit/23fd40acd4cdcd5fdbedbea73a71ec9e78ae7184.

The first half of the second comment, #x+10, has been addressed in https://github.com/s-expressionists/Eclector/commit/6e209285c8cd74190aaf1dbda13d3c647aaf755e.

The potential problem with #10r10. remains for now as the right behavior is less clear.

scymtym avatar Apr 05 '25 15:04 scymtym