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

Macros -> declarations



    Date: Mon, 6 May 85 17:43 EDT
    From: David A. Moon <Moon@SCRC-STONY-BROOK.ARPA>

	Date: Monday, 6 May 1985, 11:43-EDT
	From: Guy Steele <gls%AQUINAS@THINK.ARPA>

	I would be not at all unhappy if this feature were to go away...

    I have no opinion one way or the other about whether the feature of macros
    expanding into DECLARE forms should be retained or flushed.  Maybe we'll
    hear from KMP what he had in mind when he suggested it, back in 1982 or
    thereabouts, before we make a decision. ...

Thanks for reminding me about this. Indeed, I did have reasons other than the
ones I've seen mentioned thus far. I think that at least one possible use I
had in mind was for allowing macros so that you could create alternate syntax 
for declarations. eg, suppose a BIT-REGISTER was some abstraction on special 
variables that hold fixnums. Then

 (DEFMACRO DECLARE-BIT-REGISTER (&REST NAMES)
   `(DECLARE (SPECIAL ,@NAMES)
             (FIXNUM  ,@NAMES)))
   
might be something you could imagine writing and

 (DEFUN FROB (REG)
   (DECLARE-BIT-REGISTER REG)
   (FROB-1))

 (DEFUN FROB-1 ()
   (DECLARE-BIT-REGISTER REG)
   ...)

might be a sample usage. Note that in this situation it is not the case that
DEFVAR or the like is called for, since we're only communicating between two
functions. Also, one may not want to write:

 (DEFUN FROB (REG)
   (DECLARE (SPECIAL REG) (FIXNUM REG))
   (FROB-1))

 (DEFUN FROB-1 ()
   (DECLARE (SPECIAL REG) (FIXNUM REG))
   ...)

because that loses an abstraction level.

By the way, abstractions like my DECLARE-BIT-REGISTER do not provide "room for"
other declarations. Eg, consider:

 (DEFUN FOO (REG)
   (DECLARE-BIT-REGISTER REG)
   (DECLARE (SPECIAL *FOO*))
   ...)

There is no way (without violating the BIT-REGISTER abstraction) to not write
two leading DECLAREs.