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


Sigh, the DESTRUCTURING-BIND discussion made it clear that it's time to
deal with a couple of details about DEFMACRO which have been left vague...

Forum:	      Cleanup
References:   8.1 Macro Definition (CLtL pp144-151),
Edit history: 30-Jan-89, Version 1 by Pitman
Status:	      For Internal Discussion

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 the top level of a DEFMACRO
        lambda list.

     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) D) ...) is undefined.

     (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. At top level, &WHOLE and &REST do something different, so two
	keywords are warranted. Embedded, there is only a need for &REST.
	Providing &WHOLE would just encourage confusion among novices.

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

	This also reduces the temptation for novices to confuse &WHOLE
	with &REST.

     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. Since the proposal is to make
	this situation is undefined, this is technically compatible.
     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
     &REST). Since this proposal also outlaws &WHOLE at recursive levels,
     it is technically compatible.

Cost to Implementors:

  None. This change is upward compatible.

  Note in particular that implementations which currently do not error check
  the pattern when &WHOLE is used are technically compatible, since that
  situation is made "undefined" by this proposal. This basically just
  restricts the set of things users can do in portable code.

Cost to Users:

  Very slight. Probably most users don't do any of the things this proposal
  addresses. If they do, most cases can probably trivially be found and fixed
  by very superficial editing. In any case, any code which touches on these
  areas is probably already not portable.

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.