[Openmcl-devel] when is :<BOOL> == T?

Randall Beer beer at eecs.cwru.edu
Fri Aug 5 12:49:31 PDT 2005


As far as I recall, :<BOOL>s always expect T/NIL, unless this has  
changed in the new SEND stuff that Gary has been doing.  I *think*  
that any untyped argument in a DEFINE-OBJC-METHOD defaults to :ID,  
which is probably not what you want.

Randy


On Aug 5, 2005, at 1:07 PM, alex crain wrote:


>
>
> I was working with this method definition
>
> (define-objc-method ((:unsigned :dragging-source-operation-mask-for- 
> local (:<BOOL> is-local))
>              hemlock-text-view)
>   (if (= is-local #$YES)
>       (logior #$NSDragOperationCopy #$NSDragOperationMove)
>     #$NSDragOperationCopy))
>
> Which throws an exception because is-local is either T or nil, not # 
> $YES or #$NO.
>
> This kind of makes sense and kind of doesn't
>
> What are the rules for :<BOOL> objects? are they always translated  
> correctly, so that
>
> (send view :set-hidden T)
> is correct and
> (send view :is-hidden) => T
> ?
> Can I/Should I ever do (send view :set-hidden #$YES)
>
> It would seem like if this were going to be the case, then #$YES  
> should EQ T and #$NO should EQ NIL.
>
> This gets more complex because if I don't specify the argument  
> type, as in
>
> (define-objc-method ((:unsigned :dragging-source-operation-mask-for- 
> local is-local)
>              hemlock-text-view)
>   (if  (= is-local #$YES)
>       (logior #$NSDragOperationCopy #$NSDragOperationMove)
>     #$NSDragOperationCopy))
>
> is-local now comes through as #$YES or #$NO.
>
> The whole thing strikes me as reverse-intuitive: if I know enough  
> to specify the ObjC type for a variable, OpenMCL
> converts it to an incompatible lisp type. If I don't know what it  
> is, it comes over as the raw ObjC value.
>
> I like the idea of making ObjC booleans into simple lisp booleans,  
> but it seems more confusing then it's worth.
> Maybe it would be better to just have an OBJC-IS-TRUE primitive?
>
> :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