-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Kalle Sommer Nielsen wrote:
> Then ZF should provide an error handler that can be called inside the
> user's error handler or simply choose to not use error handlers if the
> user have a custom error handler. I can't really see why the whole
> language should change into using exceptions by default because of
> something like this?

This second suggested solution doesn't change the current behaviour at
all, just adds an additional one, which under usual circumstances will
never appear.

Again, say for example, you have the following code:

- ------------------------------
$fp = @fopen(...);
if (!$fp) {
    // !some! error occured, handle it
}
- ------------------------------

I already described the problems with this in the RFC, e.g. you don't
know, which error occurded, just that fopen failed. What a library
currently would have to do is:

- ------------------------------
function exception_error_handler($errno, $errstr, $errfile, $errline ) {
    throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
set_error_handler('exception_error_handler');

try {
    $fp = fopen(…);
} catch (ErrorException $e) {
    // Handle the exception
}

restore_error_handler();
- ------------------------------

One could surely do that, yet it is not only unneccesary much additional
code, but also introduces overhead by setting and restoring the error
handler again and again.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkppwAEACgkQ0HfT5Ws789DWiACgybJm1vq+Hrmtm0s1zoJ4sS0n
TzoAnRtx6fT9CFn+zn8goCWByxIij6np
=cmFn
-----END PGP SIGNATURE-----

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

Reply via email to