Hello Jevon, Friday, April 16, 2004, 1:05:11 AM, you 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.) That doesn't work in PHP or better say it doesn't make sense since many things in PHP are done dynamically at runtime so there wouldn't be compiletime exception declaration. Generally when i worked with declared exceptions i hated the rare situations where an undeclared exception comes into place because suddenly all your errorhandling is out of order. For PHP this situation would be more or less the standard. marcus -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php