Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sdd.hp.com!elroy.jpl.nasa.gov!decwrl!deccrl!bloom-beacon!eru!hagbard!sunic!mcsun!ukc!mucs!m1!bevan From: bevan@cs.man.ac.uk (Stephen J Bevan) Newsgroups: comp.lang.scheme Subject: REPOST : Exception handling - how to define it ? Message-ID: Date: 5 Apr 91 08:03:48 GMT Sender: news@cs.man.ac.uk Distribution: comp Organization: Department of Computer Science, University of Manchester Lines: 40 [I originally posted this on the 29th of March, but I've a feeling it never made it off my local site. If it did, then I appologise for wasting time (and money) with a question nobody seems to be able to answer] 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 off course trying to use exceptions in Scheme? All answers greatefully received. Stephen J. Bevan bevan@cs.man.ac.uk