[Openmcl-devel] Using Cocoa with MCL
Gary Byers
gb at clozure.com
Fri May 9 15:46:19 PDT 2003
On Fri, 9 May 2003, Yannick Versley wrote:
[other interesting stuff, and]:
> OpenMCL currently cannot handle ObjC exceptions, and this seems to be
> hard to do on the lisp side since _setjmp() does nothing useful when
> invoked from lisp. This is sad because as of 13.4, ObjC exceptions
> invoke some trap that is deep inside Stuff You Don't Want To Know About
> and does nothing useful.
>
> Cheers,
> Yannick
>
There might be some way to do what #_setjmp does (establish something
like a CATCH frame that #_longjmp can do something like THROW to). It
probably won't ever "work" to use #_setjmp from lisp (as if #_setjmp
was just a normal function call and not magic), but it seems like it
may be possible to do something like:
(rlet ((buf :jmp_buf))
(catch :some-tag
(%%associate-jmp-buf-with-current-catch-frame buf)
(progn
(whatever)))) ; that association needs to be broken; perhaps
this'd work better if it was nested differently
If a jmp_buf was "associated" with a catch frame (and this all worked),
then #_longjmp to that jmp_buf would behave exactly like a THROW to
that frame's tag. There are lots of gory details and complications,
but this might (with suitable macrology to hide those details) make
it possible to write ObjC-visible exception handlers in lisp.
The next nasty surprise awaiting us is the observation that merely
transferring control to the right place (via #_longjmp) isn't
adequate: THROW "unwinds the stack" on the way to its target,
discarding intervening CATCH frames and executing intervening
UNWIND-PROTECT cleanup forms. If there's a reasonably sane way to
patch #_longjmp (kind of sounds like an oxymoron already) so that it
does the right thing, it seems like it'd be worth the effort to do
so.
The ObjC runtime maintains a per-thread LIFO list of exception
handlers; THROW is ordinarily blissfully unaware of this. I'm not
sure how to effect this, but throwing "past" an ObjC exception
handler should ideally remove that handler from the per-thread
list.
_______________________________________________
Openmcl-devel mailing list
Openmcl-devel at clozure.com
http://clozure.com/cgi-bin/mailman/listinfo/openmcl-devel
More information about the Openmcl-devel
mailing list