Can compiler macros make use of type declarations?

Martin Simmons martin at lispworks.com
Thu Nov 9 12:04:55 UTC 2017


>>>>> On Thu, 09 Nov 2017 12:38:56 +0100, Stelian Ionescu said:
> 
> > Compiler macros are expanded too early to get inferred type info.  For
> > example,
> > 
> > (let ((y 10)) (loop (bar y) (setq y :not-a-fixnum)))
> 
> Would it be against the standard to do some type analysis before expanding
> compiler macros ?

Probably not against the standard, but not much analysis is possible.
Afterall, you have to expand macros and compiler macros before their
expansions can be analyzed.  You can't infer the type of a variable unless you
know the types of all of the values assigned to it.


>                   Without that, compiler macros can only make optimization
> decisions based on arguments which are literal values, which is still useful
> but not in all cases.

Yes, that's really all they can be used for.

-- 
Martin Simmons
LispWorks Ltd
http://www.lispworks.com/



More information about the pro mailing list