[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Issue: DOTTED-MACRO-FORMS (Version 1)
- To: CL-Cleanup@SAIL.Stanford.EDU
- Subject: Issue: DOTTED-MACRO-FORMS (Version 1)
- From: Kent M Pitman <KMP@STONY-BROOK.SCRC.Symbolics.COM>
- Date: Tue, 28 Jun 88 16:47 EDT
- Cc: goldman@VAXA.ISI.EDU
- References: The message of 14 Jun 88 17:32 EDT from goldman@VAXA.ISI.EDU
Issue: DOTTED-MACRO-FORMS
References: forms (p54), lists and dotted lists (pp26-27),
DEFMACRO (p145), destructuring macro arguments (p146)
Category: CLARIFICATION
Edit history: 28-Jun-88, Version 1 by Pitman
Status: For Internal Discussion
Problem Description:
CLtL is not explicit about whether macro forms may be dotted lists.
p54 says that only certain forms are "meaningful": self-evaluating
forms, symbols, and "lists".
pp26-27 defines "list" and "dotted list". It goes on to say
``Throughout this manual, unless otherwise specified, it is an
error to pass a dotted list to a function that is specified
to require a list as an argument.''
p146 states that in DEFMACRO destructuring, ``the argument
form that would match the parameter is treated as a
(possibly dotted) list, to be used as an argument forms list
for satisfying the parameters in the embedded lambda list.''
It goes on to say that ". var" is treated like "&rest var"
at any level of the defmacro lambda-list.
Test Case:
#1: (DEFMACRO MACW (&WHOLE W &REST R) `(- ,(CDR W)))
(MACW . 1) => ??
#2: (DEFMACRO MACR (&REST R) `(- ,R))
(MACR . 1) => ??
#3: (DEFMACRO MACX (&WHOLE W) `(- ,(CDR W)))
(MACX . 1)
Current Practice:
A. Some implementations bind W to (MACW . 1) in #1 and #3
and bind R to 1 in #1 and #2.
B. Some implementations bind W to (MACW . 1) in #3
and signal a syntax error in #1 and #2.
C. Some implementations signal a syntax error in #1, #2, and #3.
Symbolics Genera is such an implementation.
Proposal (DOTTED-MACRO-FORMS:EXPLICITLY-VAGUE):
Clarify that it is an error for a macro form to be a dotted list.
Rationale:
Makes current practice explicit.
Dotted lists are a possible symptom of program syntax error.
Allowing implementations to check for this error may catch enough
errors to justify the loss of program flexibility.
Test Case:
(MACW . 1) would be an error under this proposal.
(MACR . 1) would be an error under this proposal.
Cost to Implementors:
None. This is merely a clarification of existing practice.
Cost to Users:
None. Users already can't rely on this behavior since it varies
widely between implementations already.
Proposal (DOTTED-MACRO-FORMS:ALLOW):
Clarify that if &REST occurs in a DEFMACRO lambda-list, it is permitted
to match an atom or dotted list.
Rationale:
This is more flexible, and there is no efficiency or compatibility
argument for not allowing it.
Test Case:
(MACW . 1) would reliably return -1 under this proposal.
(MACR . 1) would reliably return -1 under this proposal.
Cost to Implementors:
Generally trivial. In most cases, some error checking might have to
be removed or the algorithm used by the destructuring bind primitives
might have to be modified slightly.
Cost to Users:
None. Users already can't rely on this behavior since it varies
widely between implementations already.
Cost of Non-Adoption:
Some users would continue to incorrectly believe the behavior
was well-defined, and portability problems would result.
Benefits:
People would know what to expect.
Aesthetics:
Some people believe that dotted forms are ugly. Disallowing dotted forms
would make them happier.
Some people believe that there's no reason to unnecessarily restrict
&WHOLE and/or &REST since there is no computational overhead and since
the interpretation, if there is one at all, is pretty well agreed upon.
Most importantly, however, we should be clear about what we intend or allow.
If this is well-defined, we should say how.
If this is not well-defined, we should say so.
Discussion:
Goldman@VAXA.ISI.EDU raised this issue on Common-Lisp.
Pitman converted Goldman's mail to this formal proposal, but some
parts had to change in the process because of some apparent confusion
in the original message about the number of arguments permitted when
an &WHOLE variable is the only variable in a lambda list. Pitman
believes you must write (&WHOLE W &REST IGNORE) in the case where
Goldman as using just (&WHOLE W).
Goldman's message seemed to suggest we adopt something similar to
DOTTED-MACRO-FORMS:ALLOW.
Pitman supports DOTTED-MACRO-FORMS:EXPLICITLY-VAGUE.