On 10/22/2013 07:32 PM, Patrick Schaaf wrote:
Am 22.10.2013 20:07 schrieb "Joe Watkins" <krak...@php.net>:
You can catch exceptions, and log them.
You can do that without impacting everything around you, you can do that,
or whatever else you like.
You can do that handling when you have only a few toplevel scripts, like
when you have a setup with a small number of toplevel controllers and
almost no CLI stuff around. But due to the scoped nature of try/catch you
cannot reasonably / painlessly do that when you have 270 toplevel web and
CLI entry points that then each need such a try/catch block.
Also, there is the problem with catch (Exception) blocks, which you might
easily dismiss as bad form, but which I'm sure are widespread in the field
- I certainly know they are in our codebase...
On the other hand, setup of an assertion-failed callback can easily go into
an auto_prepend file, or into any other standard include (autoloader or
something) you might have - exactly because it is something done on the
global level instead of the scoped try/catch requirement. And IF you like
the exception thing you can make that callback throw whatever you like -
but you do not force that model on everybody.
Furthermore such an assertion-failed callback has exactly the same change
of looking at backtraces, so touting that as a singular feature of the
exception approach is not valid.
Finally, with the exception approach it is simply not true that it will
completely go away in production - because these try/catch blocks will be
present for any code that wants to handle the issue, and you cannot make
those go away.
I'm all for an assert alternative that works with expressions instead of
eval, and that completely goes away in the opcode (cache) when disabled in
production.
best regards
Patrick
I was pretty explicit: used properly.
We are going round in circles, discussing what assertion should be used
for, again.
Production code should _NOT_ have catch blocks everywhere to manage
exceptions that will NEVER be thrown, obviously.
assertion is a debug and development feature, if you take code to
production that catches exceptions that your configuration does not
allow to be thrown then that's pretty silly.
assertion should be used during development, in development environments
where it is enabled, by the time your code goes to production it should
not suffer ExpectationExceptions and cannot anyway.
I think this thread and the RFC now contains enough information
regarding exceptions, it is now covered ground.
Cheers
Joe
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php