[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Exception handling in R5RS

I agree that Pavel's way of doing exceptions is better than the way
that I proposed.  I think that something like HANDLER-CASE is
necessary - I don't want to have to type

 (lambda (k)
    (lambda (exception)
      (if (is-open-file-exception? exception)
	  (k (do-stuff-to exception))
    (lambda ()
      (open-input-file filename)))))

every time I want to safely open a file.  If you don't like adding
extra syntax to scheme, one possibility might be to add a function
DO-HANDLER (or whatever) defined as follows:

(define DO-HANDLER
  (lambda (thunk predicate action)
     (lambda (k)
	(lambda (exception)
	  (if (predicate exception)
	      (k (action exception))

which would transform the above into the rather more manageable

(do-handler (lambda () (open-input-file filename))

- this would do about as much as you can do to capture that idiom
without adding extra syntax.

What do the exceptions returned by the library functions in
SchemeXerox look like?  It wouldn't be so useful to add this kind of
stuff to Scheme without being able to easily catch errors signalled by
the standard library.  Another thing that I might want to do is be
able to globally modify the signal handler (i.e. to modify the
'default' signal handler that gets called if no other signal handler
intervenes), but it would probably be better to just add eval to the
language and let users write their own repl loops.

david carlton