[Openmcl-devel] Snow Leopard snafu

Ron Garret ron at flownet.com
Tue Sep 1 10:44:09 PDT 2009


On Sep 1, 2009, at 10:30 AM, R. Matthew Emerson wrote:

>
> On Sep 1, 2009, at 12:59 PM, Ron Garret wrote:
>
>> Oh blarg, this doesn't work either:
>>
>> ? (make-instance gui::ns-lisp-string :with-string (coerce "foo"
>> 'simple-base-string))
>>> Error: value "foo" is not of the expected type (OR MACPTR NULL).
>>
>> So let me just ask: what is the Right Way to convert a Lisp string to
>> an NSString nowadays?
>
> There's the (unexported) macro CCL::WITH-AUTORELEASED-NSSTRINGS,  
> that works like this:
>
> (ccl::with-autoreleased-nsstrings ((s1 "foo") (s2 "bar"))
>  (#/initWithObjects: (#/alloc ns:ns-array) s1 s2 +null-ptr+))
>
> This is somewhat nicer than fiddling with %MAKE-NSSTRING.  (And it's  
> analogous to macros such as WITH-ENCODED-CSTRS and so forth that are  
> part of documented CCL.)
>

Thanks!

> I would have exported it, but I'm not sure what package it should go  
> in,

Seems to me anything GUI-related ought to go in the GUI package.  But  
what do I know?

> and whether it should really be WITH-CFSTRINGS.
>


I wouldn't worry too much about this.  Much more important to have a  
stable API even if the names are slightly wrong (people can always  
build wrappers if they find the name you chose intolerable) than to  
have to deal with old code suddenly not working because something  
changed behind the scenes.  And something as basic as an NSString/ 
CFString really needs a stable API.  (Once upon a time you could just  
pass Lisp strings to Cocoa functions and the ObjC bridge did the  
conversion automagically.  Those were the days.)

rg

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20090901/862b5c3a/attachment.htm>


More information about the Openmcl-devel mailing list