Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!munnari.oz.au!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.prolog Subject: Re: Trapping interrupts cleanly Message-ID: <6201@goanna.cs.rmit.oz.au> Date: 10 Jun 91 12:25:04 GMT References: <9105310922.AA22183@ucbvax.Berkeley.EDU> <1991Jun3.071610.23645@ecrc.de> Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 45 In article <1991Jun3.071610.23645@ecrc.de>, dahmen@ecrc.de (Michael Dahmen) writes: > I suggest to use a non-local exit construct (block/3, exit_block/1). > I am not sure, but I think block/3 and exit_block/1 are part of the > proposed Prolog standard, and many Prolog implementation already > include them. The operations were proposed to the BSI in late 1984 under the rather less obscure names (I often use T, and so for me block=begin=progn) if_error/3 and signal_error/1. They are present in Quintus Prolog under slightly different names. ALS Prolog has them as `catch' and `throw', which fits the cultural context. NU Prolog also has them. IBM Prolog has a similar feature. No doubt there are many others. block/3 and exit_block/1 are by far the very worst names I've seen. There is a subtle difference between NU Prolog's and the version proposed in 1984. The 1984 version undoes bindings; NU Prolog's equivalent does not. That is due to the interaction of exception handling with coroutining. I now think that it would be most unwise for the ISO committee to include these operations in the standard until they have understood the interaction between exception handling and coroutining. (For example, in the presence of coroutining, it need not be true that signalling an exception results in the ``block'' (what's a block) being ``exited''. Scheme programmers who use full continuations are only too painfully aware of the kind of thing that can happen. The price we pay for power!) > [Semantics: block(Goal, Tag, Recovery) calls Goal. If during evaluation > of Goal an exit_block(ExitTag) occurs, such that ExitTag and Tag unify, > then Recovery is called. Afterwards execution continues as if block/3 > has been replaced by call(Recovery). If no exit_block/1 occurs, block/3 > behaves like once(Goal).] That is obscene. Quintus's implementation of the 1984 proposal has if_exception(ErrorDescription, Goal, Handler) acting like call(Goal) in the absence of an exception, and like (E = ErrorDescription -> call(Handler) ; signal_exception(E)) if an error described by the term E occurs. There is no shadow of a trace of an excuse for making if_error/3 act like once/1. (No, that does _not_ "fix" the interaction with coroutining.) -- Should you ever intend to dull the wits of a young man and to incapacitate his brains for any kind of thought whatever, then you cannot do better than give him Hegel to read. -- Schopenhauer.