Skip to content

Macro lambda lists do not accept dotted lists (again) & dotted lists with quasiquote #1808

Description

@Gleefre

Describe the bug
Same as #106:

(defmacro foo (x . y))
(macrolet ((foo (x . y))))

both result in

Condition of type: TYPE-ERROR
Y is not of type LIST.
Available restarts:
(use :r1 to invoke restart 1, etc.)

1. (RESTART-TOPLEVEL) Go back to Top-Level REPL.

(ERROR TYPE-ERROR :DATUM Y :EXPECTED-TYPE LIST)

Context
Tested on the current head version.

(lisp-implementation-version) ; => "clasp-boehmprecise-3.0.1-67-gda70d6ff1-non-cst"

Some minor analysis
This seems to be caused by the following lines:

(defun cross-clasp.clasp.ext:parse-macro (name lambda-list body &optional env)
(ecclesia:parse-macro-using-canonicalization name lambda-list body env
`((lambda-name (macro-function ,name))
(lambda-list ,@lambda-list))))

Changing (lambda-list ,@lambda-list) to ,(list* 'lambda-list lambda-list) or something similar would likely solve the issue.

Quasiquote
The code above causes an issue because per hyperspec, `(,@list) could be treated as both (append dotted-list nil) and (list* list), meaning that whether list can be a dotted list (or a circular list), or if must be a proper list is not quite well-defined.

It seems that Eclector does not allow for dotted lists in this context, thus the error. That also means that this issue would likely be resolved without any changes needed here if this behavior was changed in Eclector, see s-expressionists/Eclector#60.

Note that most other lisp implementations allow for dotted lists in this context. (I tested the following implementations: sbcl, cmucl, ccl, ecl, abcl, clisp, jscl, allegro cl and lispworks; and they all allow it).

Also, there is a good explanation of this issue in the readme of fare-quasiquote, a known portable quasiquote implementation. It itself allows dotted lists by default, although it can be disabled by adding :quasiquote-strict-append to the features before compiling the system.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions