Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!snorkelwacker.mit.edu!bloom-beacon!eru!kth.se!sunic!mcsun!ukc!mucs!m1!bevan From: bevan@cs.man.ac.uk (Stephen J Bevan) Newsgroups: comp.lang.scheme Subject: Exception handling - how to define it ? Message-ID: Date: 29 Mar 91 11:44:49 GMT Sender: news@cs.man.ac.uk Distribution: comp Organization: Department of Computer Science, University of Manchester Lines: 35 What is the general style used to write exceptions and their handlers in Scheme? By exceptions I mean facilities similar to catch/throw in Lisp. The ways I can see of doing it are :- 1) Pass a success and fail continuation to every function. 2) Pass multiple continuations, one for each error to be handled. 3) Call a function that is assumed to be set by the user e.g. (define (foo x y z) ... (if (some-unexpected-error) (unexpected-error-exception args) ...)) where `unexpected-end-of-file-exception' as a default just aborts. It would be up the user to re-define this as appropriate. I guess the easiest way of doing this would be via fluid-let e.g. :- (fluid-let ((unexpected-error-exception (lambda x (do-something-sensible x)))) (foo an-arg another-arg yet-another-arg)) However, as fluid-let isn't part of the standard (as far as I'm aware), this solution isn't portable. So some questions :- * Are there better mechanisms that those above? * Any opinons as to which is the best? * Am I totally of course trying to use exceptions in Scheme? All answers greatefully received. Stephen J. Bevan bevan@cs.man.ac.uk