Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:69778 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 58613 invoked from network); 22 Oct 2013 18:47:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Oct 2013 18:47:28 -0000 X-Host-Fingerprint: 80.4.21.210 cpc22-asfd3-2-0-cust209.1-2.cable.virginm.net Received: from [80.4.21.210] ([80.4.21.210:19529] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FB/BA-10840-048C6625 for ; Tue, 22 Oct 2013 14:47:28 -0400 To: internals@lists.php.net,Patrick Schaaf Message-ID: <5266C83C.1060200@php.net> Date: Tue, 22 Oct 2013 19:47:24 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 References: <3D.BC.23638.84CA1625@pb1.pair.com> <5264FE65.8050808@php.net> <5266B6A8.4010607@pthreads.org> <5266BECD.8000204@php.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 80.4.21.210 Subject: Re: [PHP-DEV] RFC: Expectations From: krakjoe@php.net (Joe Watkins) On 10/22/2013 07:32 PM, Patrick Schaaf wrote: > Am 22.10.2013 20:07 schrieb "Joe Watkins" : >> >> 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