This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

catch/throw functionality


I am currently implementing exception handling in Kawa, and I have
some questions about similar features in Guile.  Specifically,
I am looking for a high-level Scheme interface that does not
require call/cc, and I would prefer to implement something
compatible with Guile and/or other Scheme implementations,
rather than design my own.

The Guile reference manual describes catch and throw.
Are these interfaces considered stable?  Or are any changes
planned?

There is one feature I fail to see the point of:

     Key may also be the value `#f'.  In that case, THUNK takes one
     argument which will be passed a "jump buffer object".  A jump
     buffer object may be used as the key argument to `throw' to throw
     to a specific `catch' without an intervening search for a symbolic
     key.

Assuming you have a gensym function that returns an unique symbol,
am I right in believing that:
	(catch #f THUNK HANDLER)
is equivalent to:
	(let ((jbuf (gensym))) (catch jbuf (lambda () (THUNK jbuf)) HANDLER))

If so, then it seems like a feature that fail to justify the extra
conceptual complication to catch.  (I can implement it easily enough.
It is just very ugly, in a type sense.)

The Scheme repository includes one "Proposal for Exception Handling in Scheme"
-see http://www.cs.indiana.edu/scheme-repository/doc.proposals.exceptions.html.
This proposal (which I believe matches MzScheme) looks implementable in Kawa
without too much trouble.  However, it assumes the MzScheme convention
for "parameters" as 0-or-1-adic functions, which I don't particularly
care for, and it does not look like it would fit well with either
Guile or Kawa.

	--Per Bothner
Cygnus Solutions     bothner@cygnus.com     http://www.cygnus.com/~bothner