rif wrote:
> (What I am actually trying to do is rewrite a piece of uffi --- I
want
> get-slot-value to expand into a form that includes a type declaration
> on CMUCL, for efficiency reasons. In uffi:get-slot-value, you pass a
> quoted type name, but the CMUCL type declaration requires the name
> unquoted.)
>
One thing you have to beware of is that the type declaration might be
a computed thing, or that it's constantness might not be as simple as
looking for (QUOTE x) - for instance it might be the value of a
constant variable. CONSTANTP can help here, as it offers the
possibility of detecting some things (although clearly not all things)
which are constant even if they are not `obviously' constant, and
which you can then safely evaluate at macro expansion time.
However, it seems to me that a perfectly possible optimisation for a
compiler would be something like this:
(let ((x <something>))
(cond ((typep x <type>)
<forms>)
(t (error ...))))
Now, the compiler can ask if <type> is CONSTANTP (or possibly use some
better implementation-specific predicate) and transform this into code
where <forms> is in the scope of a type declaration for x. CMUCL is
exactly the kind of implementation that might be up to this sort of
thing, so it might be worth checking if it does it.
--tim