George Schlossnagle wrote:


On Feb 13, 2004, at 11:35 AM, Adam Maccabee Trachtenberg wrote:


Andi's point, I believe, is that otherwise we'll need to add a
"finally" keyword to make sure some random extension doesn't throw
some random undocumented exception that you could miss. And I agree
with him. It just seems to make everything more clean.


'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.

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.

--
Ard

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to