[Openmcl-devel] Calling STRETs without SEND

R. Matthew Emerson rme at clozure.com
Tue Jun 2 12:01:32 PDT 2009

On Jun 2, 2009, at 12:41 PM, Ron Garret wrote:

> Following an recent admonition that SEND is deprecated, I've been
> converting all my old code to call ObjC methods directly using the #/
> reader macro.  However, this doesn't seem to work for STRET calls,  
> e.g.:
> (ccl::slet ((event-location (#/locationInWindow event)) ...
> gives me:
>> Error: Unrecognized STRET call in (NEXTSTEP-FUNCTIONS:|
> locationInWindow| EVENT)
>> While executing: CCL::SLETIFY, in process Listener(7).
> while:
> (ccl::slet ((event-location (send event 'location-In-Window)) ...
> works.
> The examples in the manual also use SEND.
> What is the proper way to call STRETs?

When using #/ notation, you don't need to make a distinction between  
methods that return a structure by value, and those that don't.  So  
you can just say

(let ((event-location (#/locationInWindow event)))

and forget about SLET entirely.

There's some information about the use of the #/ reader macro in  
ccl:doc;release-notes-1.1.txt;  here's an excerpt:

  ObjC methods that "return" structures return them as gcable pointers
  when called via dispatch functions.  E.g., if "my-window" is an
  NS:NS-WINDOW instance, then

(#/frame my-window)

  will return a gcable pointer to a structure that describes that  
  frame rectangle.  (The good news is that there's no need to use SLET
  or special structure-returning message send syntax; the bad news is
  that #_malloc, #_free, and the GC are all involved in the creation
  and eventual destruction of structure-typed return values.  Unless
  and until those factors negatively affect performance, the advantages
  seem to outweigh the disadvantages.)

Sorry that section 13 of the manual is so out-of-date.

More information about the Openmcl-devel mailing list