[Openmcl-devel] compiler bug?

Randall Beer beer at eecs.cwru.edu
Sat Sep 18 06:30:17 PDT 2004


> can't we just make (constantp x) be (numberp x)?
> I can't imagine a case where x would be anything else (other then 
> something that needs to be evaluated)
> :alex

This certainly works. However, it doesn't "expand away" as much of the 
computation as it could.  For example, with this definition, we get

? (macroexpand '(coerce-to-foreign-type #$NO :char))
(LET ((#:G2043 OS::NO))
    (IF (OR (EQ #:G2043 0) (NULL #:G2043))
         OS::NO
         OS::YES))
T

so that the test is still being done at runtime. Whereas with the EVAL 
change I made last night, we get.

? (macroexpand '(coerce-to-foreign-type #$NO :char))
0
T

Because these conversions have to happen for *every* argument passed 
into *every* message send, I was trying to do as much at compile-time 
as I possibly could.

BTW, my earlier bug shows once again why one should NOT use macros to 
address these sorts of efficiency concerns.  Instead, one should use 
functions with appropriate compiler macros to optimize the special 
cases (such as constant object and/or foreign type). I know this, but 
unfortunately still don't always do it.

Randy




More information about the Openmcl-devel mailing list