n fact, I'm writing a Cocoa MUD client that communicates w/ a lisp
engine via standard io. There's really no conceptual difference between
that and a socket of some kind, I just chose it because I wanted very
direct control of the lisp reader.
<br><br>It's not terribly hard to do. I have a LispREPL class
encapsulating the message passing (and I added categories to
NSDictionary/Array/etc to get lisp representations). On top of that is
a LispREPLController which provides the UI glue (I have my own listener
window, rather than using OpenMCL's built in cocoa listener).
<br><br>Messages are passed as s-exps. On the lisp side, there's no
work at all there, of course, and on the Cocoa side, I wrote tacked on
a category to NSString to convert forms to NSArrays.<br><br>In
practice, this has worked out very well for me so far. It's extremely
easy to add Cocoa stuff to the lisp backend, and you can do it
piece-meal as you need to.
<br><br>There is one perpetual issue: since I process sexps in Cocoa
as an NSArray, I lose out on dotted conses. Since I translate from
alists to NSDictionary, there's lossage here that you need to stay
aware of . For instance, when one changes the server setting, it sends
a message like the following:
<br><br>(moxie::send-window-event :COCOA-WINDOW-ID :settings-changed '((:hostname "whatever")))<br><br>When,
ideally, it would send '((:hostname . "whatever")) so one could use
car/cdr properly. It's even worse, because if you were to send the
following message to the Cocoa end of things:
<br><br>(:window-event :COCOA-WINDOW-ID :settings-changed '((:hostname . "whatever")))<br><br>Things
will work fine from cocoa (NSDictionary/Array have no cdr concept to
run afoul of), but when you change that host from "whatever" to
"sowhat" (via Cocoa preference panels, of course), it strips that dot
out of the event:
<br><br>(moxie::send-window-event :COCOA-WINDOW-ID :settings-changed '((:hostname "sowhat")))<br><br>So
in the process of moving between cocoa and lisp, you have to be
cognizant of the fact that applying cdr to any data returned from Cocoa
will always return a list.
<br><br>It's not a huge deal, and aside from that things work quite
well. At some point I intend to wrap up the lisp communication/dispatch
into a framework so it can be used elsewhere. The only reason I haven't
done it yet is because I want a plug in system that loads lisp/cocoa
simultaneously, so someone can package lisp code w/ interface builder
NIB files, and no one would need to know a lisp is under all that.
<br><br>I tried, briefly, to embed a lisp using ECLS, but there were
an enormous amount of problems with that approach, and so I went with
running a lisp in a subprocess. It's annoying because of asynchronous
timing issues, but a win overall, imho.
<br><br>If you want the code to the lisp handler, shoot me a private
mail and I'll see about packing it up for you. It's a pretty simple
piece of code, really. The hardest part was writing the translator from
forms to NSArrays, and that didn't even take an hour.
<br><br>-bjc<br><br><div><span class="gmail_quote">On 1/24/06, <b class="gmail_sendername">Gary King</b> <<a href="mailto:email@example.com">firstname.lastname@example.org</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I know that progress continues with the Objective C / Cocoa bridge<br>but I'm wondering if anyone has worked on running OpenMCL and a Cocoa<br>application using sockets to communicate between them. I have some<br>ideas I'd like to play with where the GUI could be Cocoa and some of
<br>the smarts could be OpenMCL. I think that sockets would be fast<br>enough, etc. to handle simple needs. Unfortunately, I'm pressed for<br>time and would rather not much with setup unless I have to so...<br><br>Has anyone else build any infrastructure along these lines that
<br>they'd like to share? Also, is this a _bad_ idea? Am I missing<br>something?<br><br>Thanks,<br>--<br>Gary Warren King<br><a href="http://metabang.com">metabang.com</a><br><a href="http://www.metabang.com/">http://www.metabang.com/
</a><br><br><br>_______________________________________________<br>Openmcl-devel mailing list<br><a href="mailto:Openmclemail@example.com">Openmclfirstname.lastname@example.org</a><br><a href="http://clozure.com/mailman/listinfo/openmcl-devel">