--- This message is a formal comment which was submitted to formal-comment_at_r6rs.org, following the requirements described at: http://www.r6rs.org/process.html --- Submitter: John Cowan Email address: cowan_at_ccil.org Issue type: Defect Priority: Major Component: Exceptions Report version: 5.92 Summary: Recursive exception handling considered harmful Note: This comment is in part based on suggestions by Taylor Campbell, but he bears no responsibility for its content. In R5.92RS, a condition handler is invoked in a dynamic environment identical to that of the signaler, but with the condition handler stack popped by one frame. Failing to do so will cause the handler to be re-entered whenever an exception is raised within it, which is obviously disastrous. (Scheme48 behaves this way.) As a consequence, "raise" cannot tail-call the current handler, because it must pop and later restore the handler stack. Unfortunately, R5.92RS prescribes that a handler must reraise an exception in order to get it processed by the next handler in the dynamic chain. This loads the call stack with alternating calls to "raise" and to each handler in turn. This is a Bad Thing in an environment where there are many handlers and most only handle specific kinds of conditions. I propose, therefore, that the protocol for calling handlers be changed: 1) To decline to handle a condition and propagate it up to the next enclosing handler, a condition handler simply returns the condition that is to be propagated to the next enclosing handler. Only a constant amount of stack space, then, will delimit the handler and the signaler, regardless of how many handlers there are. No debugger traces will be cluttered by unnecessary frames caused by recursive signaling, except in the case where a procedure called by a raises a genuinely new exception. 2) In order to deal with continuable exceptions, "raise" is given a second argument, which is a continuation to be invoked if all handlers decline to handle the exception. The default value of this argument is system-dependent but does not return to the caller of "raise". The "raise-continuably" procedure is removed from R6RS. -- John Cowan http://ccil.org/~cowan cowan_at_ccil.org [P]olice in many lands are now complaining that local arrestees are insisting on having their Miranda rights read to them, just like perps in American TV cop shows. When it's explained to them that they are in a different country, where those rights do not exist, they become outraged. --Neal StephensonReceived on Wed Mar 14 2007 - 16:23:50 UTC
This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:01 UTC