Hi Ard, On Fri, 13 Feb 2004 18:45:51 +0100, Ard Biesheuvel wrote: > 'Finally' is used for code that is executed anyway, whether an exception > has occurred or not. This is different from 'catch (...)' because the > catch clause is not executed if the try block exits with no eceptions. > > Like > > try { > // open file > // do something that throws() > } > catch (Exception $e) > { > // do nothing > } > > // close file > > // re-throw > if ($e) throw $e; > > 'Finally' would be useful, but can be emulated as shown.
Ard, if the Exception class is not the base class of all exceptions(catch all), it's very difficult to emulate "finally"(You must know every exception that may be thrown inside the try block, and sometimes you don't). I really miss finally, since I'm developing a CORBA 2.3/3.0 extension for PHP5 with an idl2php language compiler(translated from OpenORB). In the compiler, for every try/catch that has finally, I have to place the finally code inside every catch block, at the end of the try block and before every return statement inside the "try" or "catch" block. It's really a pain... But I can live with it by now. :-( > Personally, I like the compulsory derivation for 'throw' operands, but I > would prefer it to be an interface instead of a class. In that case, it > is a lot easier to plug your own class (hierarchy) into the exception > framework. I agree. Cristiano Duarte -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php