[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


I didn't mean to do this, but I started. It took more time
because the last writeup really presumed that &WHOLE wasn't
allowed at inner levels, so I had to mung it to change
that assumption.

However, I really think this is just a clarification of
'current practice'; I'd be suprised to find an implementation
didn't really already conform to this. 

So I rewrote the cost/benefit section; do you know any

Forum:	      Cleanup
References:   8.1 Macro Definition (CLtL pp144-151),
Edit history: 30-Jan-89, Version 1 by Pitman
			17-Mar-89, Version 2 by Masinter

Problem Description:

  The description of the DEFMACRO lambda list currently contains some 
  mis-statements and leaves some ambiguities:

  1. Can &BODY, &WHOLE, and &ENVIRONMENT appear at recursive levels of the
     DEFMACRO lambda list?

     The description of &WHOLE (p145) specifies that &WHOLE must occur ``first
     in the lambda list,'' but the description of a lambda list says that 
     ``a lambda may [recursively] appear in place of the parameter name.''
     Consequently, the question arises whether &WHOLE should be permitted to
     be a synonym for &REST at inner levels of a DEFMACRO lambda list.

     The descriptions of &BODY and &ENVIRONMENT do not contain syntactic
     restrictions on where they may appear.

  2. Does using &WHOLE affect the pattern of arguments permitted by DEFMACRO.


  1. a. Specify that &BODY may appear at any level of a DEFMACRO lambda list.

     b. Specify that &WHOLE may only appear at any level of a DEFMACRO
        lambda list. At inner levels, the &WHOLE variable is bound to
		the corresponding part of the argument, as with &REST, but
		unlike &REST, other arguments are also allowed.

     c. Specify that &ENVIRONMENT may only appear at the top level of a
	DEFMACRO lambda list.

  2. Clarify that using &WHOLE does not affect the pattern of arguments
     specified by DEFMACRO.


  1. (DEFMACRO DM1A (&WHOLE FORM A B)  ...) is defined.
     (DEFMACRO DM1B (A (&WHOLE B C &OPTIONAL D) E) ...) is defined.
		It allows simultaneousaccess to the THIRD of the whole
		form as B and to the destructuring of that list into
		C and D.

     (DEFMACRO DM1C (A B &ENVIRONMENT ENV) ...)     is defined.
     (DEFMACRO DM1D (A (B &ENVIRONMENT ENV) C) ...) is undefined.

     (DEFMACRO DM1E (A B &BODY X) ...)     is defined.
     (DEFMACRO DM1F (A (B &BODY X) C) ...) is defined.

  2. (DEFMACRO DM2A (&WHOLE X) `',X)

     (MACROEXPAND '(DM2A))   => (QUOTE (DM2A))
     (MACROEXPAND '(DM2A A)) is an error.

     (MACROEXPAND '(DM2B))       is an error.
     (MACROEXPAND '(DM2B Q))     => (QUOTE ((DM2B Q) Q NIL))
     (MACROEXPAND '(DM2B Q R))   => (QUOTE ((DM2B Q R) Q R))
     (MACROEXPAND '(DM2B Q R S)) is an error.


  1. a. An example on p151 makes it clear that this was the intent.

	b. There's no cogent reason to forbid &WHOLE at inner levels.
     The example on p.150 uses &WHOLE in a non-top-level position.

	This simplifies the implementation of DEFMACRO if we introduce a
        DESTRUCTURING-BIND which does not understand &ENVIRONMENT.

     c. The environment is never different at top level than embedded.
	Permitting &ENVIRONMENT to occur embedded would only encourage
	the misconception that there was a potential difference.

	This simplifies the implementation of DEFMACRO if we introduce a
        DESTRUCTURING-BIND which does not understand &ENVIRONMENT.

  2. This allows useful syntax checking.

     One can always trivially write
     to get around the error checking this forces.

Current Practice:

  1. a. Symbolics Genera permits &BODY at any level. This is compatible.
     b. Symbolics Genera seems to permit &WHOLE at any level. When embedded,
	it is treated as a synonym for &REST. 
     c. Symbolics Genera does not permit &ENVIRONMENT except at top level.
	This is compatible.

  2. Symbolics Genera has this behavior when &WHOLE appears at top level,
     but not at recursive levels (where &WHOLE is treated as a synonym for

Cost to Implementors:

  This seems to be what CLtL intended and what most implementations

Cost to Users:

  We think this is possibly (probably) upward compatible with most
  current practice.

Cost of Non-Adoption:

  Some fuzzy places in DEFMACRO continue to exist.

  It's harder to introduce DESTRUCTURING-BIND because describing its relation
  to DEFMACRO is difficult.


  The language is a little tighter.


  Negligible impact.


  Part 2 of this issue came up during the discussion of DOTTED-MACRO-FORMS
  but was not pursued until now.

  Pitman supports these clarifications.

  A previous version disallowed &WHOLE at inner levels, because
  of the mistaken impression that &WHOLE was equivalent to &REST.
  However, additional arguments are not allowed after &REST,
  while they are for &WHOLE.