[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Macros -> declarations
Date: Monday, 6 May 1985 19:39-EDT
From: Kent M Pitman <KMP at SCRC-STONY-BROOK.ARPA>
Re: Macros -> declarations
By the way, abstractions like my DECLARE-BIT-REGISTER do not provide "room
for" other declarations. Eg, consider:
(DEFUN FOO (REG)
(DECLARE (SPECIAL *FOO*))
There is no way (without violating the BIT-REGISTER abstraction) to not
write two leading DECLAREs.
So what's really wanted is a DEFDECLARATION or somesuch that works like DEFTYPE
in defining a macro-like thing that expands into a list of declare forms.
Although a scheme like this wouldn't eliminate the need for a body parser to
"macroexpand" stuff at runtime, it would eliminate the screw that was the last
straw to Rob MacLachlan -- the need for all macro writers to do &environment
hacking whenever parsing bodies.
(defdeclaration bit-register (&rest guys)
(mapcan #'(lambda (guy) `((special ,guy) (fixnum ,guy))) guys))
(defun foo (reg)
(declare (bit-register reg) (special *foo*))
Note that there is no way to scope DEFTYPE's. With the above suggestion, there
would be no way to scope DEFDECLARATION's either. An alternate solution, which
requires only a one-word change to the language spec, is to restrict macros
that can expand into declarations to GLOBAL macros. This solution would handle
all of the imaginative uses for this feature that people here have come up
with, while removing the big ball of hair that makes it hard for users to write
This latter suggestion is ugly, I agree. A completely separate macro-like
mechanism is provided for types, and happens to prevent the definition of local
types, so why not have a similar mechanism for declarations?