[Openmcl-devel] forward declare an ObjC message?

Randall Beer beer at eecs.cwru.edu
Thu Feb 10 22:52:17 UTC 2005


Yes, SEND tries to optimize the call based on the name of the message.  
Using the function %SEND instead should do what you want: (%SEND 
(@CLASS A-WINDOW) 'SHOW-ME)

For what it's worth, the following will also work:

(LET ((MSG 'SHOW-ME))
   (SEND (@CLASS A-WINDOW) MSG))

because it forces SEND to expand into %SEND since the message is 
unknown at compile-time.  It should be fairly easy to change SEND so 
that it also expands into %SEND when given a constant message that is 
undefined at compile-time.

However, you must realize that using %SEND is much more expensive that 
using SEND because all of the message signature and type processing and 
foreign function call cruft will then be done at runtime rather than 
compile-time. This may be OK for some of your messages, but you 
definitely don't want to do this for any time-critical code.

The only way to forward reference messages would be to "explain" their 
types to the bridge. It should be possible to write such a utility that 
makes an entry in the type signature table fairly easily, but 
essentially it would be equivalent to giving a DEFINE-OBJC-MESSAGE 
definition with an empty body.

Randy


> I would like to reference messages before they are declared, ie:
>
> (defclass a-window ....)
>
> (defun do-something ()
> 	(send (@CLASS a-window) 'show-me))
>
> (define-objc-class-message ((:void show-me) a-window) ...)
>
> But I can't because the SEND call can't resolve the showMe message 
> name.
>
> Is there any way to forward declare the message name?
>
> :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