<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Sep 1, 2009, at 10:30 AM, R. Matthew Emerson wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><br>On Sep 1, 2009, at 12:59 PM, Ron Garret wrote:<br><br><blockquote type="cite">Oh blarg, this doesn't work either:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">? (make-instance gui::ns-lisp-string :with-string (coerce "foo"<br></blockquote><blockquote type="cite">'simple-base-string))<br></blockquote><blockquote type="cite"><blockquote type="cite">Error: value "foo" is not of the expected type (OR MACPTR NULL).<br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">So let me just ask: what is the Right Way to convert a Lisp string to<br></blockquote><blockquote type="cite">an NSString nowadays?<br></blockquote><br>There's the (unexported) macro CCL::WITH-AUTORELEASED-NSSTRINGS, that works like this:<br><br>(ccl::with-autoreleased-nsstrings ((s1 "foo") (s2 "bar"))<br>  (#/initWithObjects: (#/alloc ns:ns-array) s1 s2 +null-ptr+))<br><br>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.)<br><br></div></blockquote><div><br></div><div>Thanks!</div><br><blockquote type="cite"><div>I would have exported it, but I'm not sure what package it should go in,</div></blockquote><div><br></div><div>Seems to me anything GUI-related ought to go in the GUI package.  But what do I know?</div><br><blockquote type="cite"><div> and whether it should really be WITH-CFSTRINGS.<br><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" color="#144FAE"><br></font></font></div></blockquote></div><div><br></div><div>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.)</div><div><br></div><div>rg</div><div><br></div></body></html>