[Openmcl-devel] when is :<BOOL> == T?
alex crain
alexcrain at mail.widgetworks.com
Fri Aug 5 10:07:40 PDT 2005
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
More information about the Openmcl-devel
mailing list