Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!wuarchive!zaphod.mps.ohio-state.edu!think.com!snorkelwacker.mit.edu!ai-lab!zurich.ai.mit.edu!markf From: markf@zurich.ai.mit.edu (Mark Friedman) Newsgroups: comp.lang.scheme Subject: Re: catch/throw in scheme - how to ?? Message-ID: Date: 14 Jun 91 14:27:15 GMT References: <1991Jun10.124127.17926@eua.ericsson.se> <6246@goanna.cs.rmit.oz.au> Sender: news@ai.mit.edu Reply-To: markf@zurich.ai.mit.edu Organization: M.I.T. Artificial Intelligence Lab. Lines: 38 In-reply-to: ok@goanna.cs.rmit.oz.au's message of 13 Jun 91 05:00:56 GMT In article <6246@goanna.cs.rmit.oz.au> ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) writes: In article <1991Jun10.124127.17926@eua.ericsson.se> joe@erix.ericsson.se (Joe Armstrong) writes: > Could sombody who understands these things kindly explain how > to do the equivalent of 'catch' and 'throw' in scheme?? - > can one use call/cc for such operations? - if so how? In article , jinx@zurich.ai.mit.edu (Guillermo J. Rozas) explained how to implement catch and throw on top of call/cc. I suggest that it is simpler to use call-with-current-continuation directly. This may be true, but I think the point was that Joe Armstrong knew what catch and throw did and wanted to see how they could be implemented in terms of call-with-current-continuation. The advantage of catch and throw is that a procedure can "throw" to a "catch" which doesn't *lexically* enclose it. I can apply any escape procedure (the packaged-up form of a continuation) anywhere. The fact that catch and throw maintain a dynamic mapping of catch-tags to continuations can be convenient though. The next version of MIT Scheme will have Common Lisp style restarts, which provide that convenience plus the ability to inspect the mappings and to see dynamically shadowed mappings. -Mark -- Mark Friedman MIT Artificial Intelligence Lab 545 Technology Sq. Cambridge, Ma. 02139 markf@zurich.ai.mit.edu