Can compiler macros make use of type declarations?

Chaitanya Gupta mail at chaitanyagupta.com
Mon Nov 6 20:43:03 UTC 2017


Let's say I have created a function called `FOO`:

(defun foo (x)
  ...)

To optimize this function, I write a compiler macro. Can I make use of
type declarations that users of `FOO` might have made for the argument
`X` that is passed in to it?

That is, let's say `FOO` is used like this:

(let ((a (something-that-returns-an-integer)))
  (declare (integer a))
  (foo a))

The compiler macro for `FOO` cannot make any optimizations on the
value of `A`, but can it take advantage of the fact that `A` is
declared as in `INTEGER` here?

Chaitanya



More information about the pro mailing list