s-expressionists / wscl

Sources of the "Well Specified Common Lisp" specification which is based on the final draft of the Common Lisp standard but is not a new Common Lisp standard.
https://s-expressionists.github.io/wscl/
Other
38 stars 4 forks source link

read-delimited-list and dotted lists #23

Open lassik opened 1 year ago

lassik commented 1 year ago

CLHS does not say whether or not read-delimited-list can read dotted lists.

AFAICT, it implies by omission that a dotted list is not valid. CLISP and SBCL follow this interpretation.

informatimago commented 1 year ago

The algorithm of read-delimited-list is clearly specified in the description:

read-delimited-list looks ahead at each step for the next
non-whitespace[2] character and peeks at it as if with peek-char. If
it is char, then the character is consumed and the list of objects is
returned. If it is a constituent or escape character, then read is
used to read an object, which is added to the end of the list. If it
is a macro character, its reader macro function is called; if the
function returns a value, that value is added to the list. The
peek-ahead process is then repeated.

This algorithm is quite explicit, and leaves no room for parsing a dot and then a final object, and no room to return a dotted-list.