[Openmcl-devel] compiler bug?

Randall Beer beer at eecs.cwru.edu
Fri Sep 17 21:25:29 PDT 2004


This looks like a bug on my part.  The first case of the COND in 
COERCE-TO-FOREIGN-TYPE is passing the *symbol* X into COERCE-TO-BOOL 
rather than its value (Note that COERCE-TO-BOOL will be expanded when 
COERCE-TO-FOREIGN-TYPE is compiled). The reason for making all of these 
macros was to incur the absolute minimum overhead for these coercions, 
but I screwed up here. A quick fix is below, but there may be a better 
way to do this.

(defmacro coerce-to-foreign-type (x ftype)
   (cond ((and (constantp x) (constantp ftype))
          (case ftype
            (:id (if (null x) `(%null-ptr) (coerce-to-address x)))
            (:char (coerce-to-bool (EVAL x)))
            (t x)))
         ((constantp ftype)
          (case ftype
            (:id `(coerce-to-address ,x))
            (:char `(coerce-to-bool ,x))
            (t x)))
         (t `(case ,(if (atom ftype) ftype)
               (:id (coerce-to-address ,x))
               (:char (coerce-to-bool ,x))
               (t ,x)))))

Randy


On Sep 17, 2004, at 11:14 PM, alex crain wrote:

> Ok, I'm stumped
>
> (send text-view :set-editable #$NO) doesn't work. I notice that:
>
> (coerce-to-foreign-type 0 :char) -> 0
> but
> (coerce-to-foreign-type #$NO :char) -> 1
>
> COERCE-TO-FOREIGN-TYPE is a macro that should expand to the result if 
> (COERCE-TO-BOOL #$NO), but
> (COERCE-TO-BOOL #$NO) -> 0 like it is supposed to.
>
> I'm very interested in why this doesn't work and how to debug this 
> kind of thing.
>
> :alex
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>




More information about the Openmcl-devel mailing list