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-SUPPRESS.17 #40

Closed kpoeck closed 5 years ago

kpoeck commented 5 years ago

I believe the following should not fail:

(in-package :eclector.reader)
(multiple-value-list
              (WITH-STANDARD-IO-SYNTAX
                (LET ((*READ-SUPPRESS* T))
                  (READ-FROM-STRING "#garbage"))))
->
debugger invoked on a ECLECTOR.READTABLE:UNKNOWN-MACRO-SUB-CHARACTER in thread #<THREAD "main thread" RUNNING {10005205B3}>: g is not a sub-character of the dispatch macro character #.
scymtym commented 5 years ago

I agree that ignoring an expression such as #garbage when *read-suppress* is true could be useful, but I see two problems:

  1. #g could initiate an arbitrary syntax so it is not clear how to skip over it.

  2. The entry for Variable *read-suppress* says

    Dispatching macro characters (including sharpsign)

    Dispatching macro characters continue to parse an infix numerical argument, and invoke the dispatch function. The standardized sharpsign reader macros do not enforce any constraints on either the presence of or the value of the numerical argument.

    I take this to mean that the dispatch function is invoked and either calls a user-supplied function if the user has installed one in the readtable or calls a standard macro function or signals an error according to the table in 2.4.8 Sharpsign.

Did you find passages implying the behavior you propose?

Shinmera commented 5 years ago

From testing a few implementations in seems ABCL, CMUCL, SBCL skip over the token, and Allegro, CCL, Clasp, Clisp, ECL reject it.

scymtym commented 5 years ago

See https://irclog.tymoon.eu/freenode/%23sicl?around=1551169235#1551169235