I'm not sure how much Java code you have seen/written but this tends to lead to a million of empty try/catch statements which only lead to a false sense of security because in practice, you are barely handling any exceptions.

At 11:05 AM 4/16/2004 +1200, Jevon Wright wrote:
> Guys, I'm am not for forcing people to use exceptions. I agree that we
> should make PHP another Java exceptions from hell (especially with their
> exception declarations in function prototypes which is horrible). I'm just
> saying, that some extensions might benefit from exceptions and the
> extension author should be allowed to choose (as long as he doesn't break
BC).

But the exception declarations ensure that you don't accidentally catch an
Exception in the wrong place, eg.

function add($amount)
{
    add_money($amount) and log() or throw exception;
}

function move($amount)
{
    $from->add(-$amount);
    # It is *not* obvious here that this can fail and execution
    # might stop here! Very dangerous!
    $to->add($amount);
}

function transactions()
{
    foreach ($transaction)
    try { move($transaction->amount); } catch ...
}

You'd have to go   function move($amount) throws SomeException,   forcing
the developer to handle Exceptions at the soonest possible point...
(I'm a fan of it.)

Jevon

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

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



Reply via email to