On Mon, 14 Jan 2002, Rob Nagler wrote: > > I'm afraid I don't get it - isn't it what the "finally" functionality > > in Error.pm (CPAN) does ? > > > > try { > > stuffThatMayThrow(); > > } finally { > > releaseResources(); > > }; > > One reason for exceptions is to separate error handling code from the > normal control flow. This makes the normal control flow easier to > read. If releaseResources() is to be called whenever an exception > occurs, then it is advantageous to eliminate the extra syntax in the > class's methods and just have releaseResources() called whenever an > exception occurs and the object is on the stack. > > Our exception handling class searches down the stack looking for > objects which implement handle_die(). It then calls > $object->handle_die($die), where $die is the exception instance. This > increases the cost and complexity of exception handling, while > decreasing the cost and complexity of normal control flow. It also > ensures that whenever the object is involved in an exception, > handle_die() is called giving it an opportunity to examine the > exception and clean up global state if necessary.
Might be a fun thing to try out using the mysterious PROPOGATE method (try it - implement a PROPOGATE method in your exception class, and watch for when it gets called). -- <!-- Matt --> <:->Get a smart net</:->