Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62657 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 31583 invoked from network); 2 Sep 2012 08:10:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Sep 2012 08:10:35 -0000 Authentication-Results: pb1.pair.com header.from=lester@lsces.co.uk; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=lester@lsces.co.uk; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lsces.co.uk from 213.123.20.131 cause and error) X-PHP-List-Original-Sender: lester@lsces.co.uk X-Host-Fingerprint: 213.123.20.131 c2bthomr13.btconnect.com Received: from [213.123.20.131] ([213.123.20.131:42331] helo=mail.btconnect.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 35/43-17065-87413405 for ; Sun, 02 Sep 2012 04:10:33 -0400 Received: from host81-138-11-136.in-addr.btopenworld.com (EHLO _10.0.0.5_) ([81.138.11.136]) by c2bthomr13.btconnect.com with ESMTP id IXK20799; Sun, 02 Sep 2012 09:10:30 +0100 (BST) Message-ID: <50431474.1040001@lsces.co.uk> Date: Sun, 02 Sep 2012 09:10:28 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120604 Firefox/13.0 SeaMonkey/2.10 MIME-Version: 1.0 To: PHP internals References: <5040DC47.8000305@ajf.me> <5040F4D9.80206@sugarcrm.com> <5042946A.80204@sugarcrm.com> <5042A7D6.7050001@lerdorf.com> <5042B140.4070307@lerdorf.com> In-Reply-To: <5042B140.4070307@lerdorf.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Mirapoint-IP-Reputation: reputation=Fair-1, source=Queried, refid=tid=0001.0A0B0301.50431475.0030, actions=tag X-Junkmail-Premium-Raw: score=7/50, refid=2.7.2:2012.9.2.72142:17:7.944, ip=81.138.11.136, rules=__MOZILLA_MSGID, __HAS_MSGID, __SANE_MSGID, __FW_1LN_BOT_MSGID, __HAS_FROM, __USER_AGENT, __MIME_VERSION, __TO_MALFORMED_2, __BOUNCE_CHALLENGE_SUBJ, __BOUNCE_NDR_SUBJ_EXEMPT, __CT, __CT_TEXT_PLAIN, __CTE, __ANY_URI, __URI_NO_MAILTO, __URI_NO_WWW, __CP_URI_IN_BODY, BODY_ENDS_IN_URL, BODYTEXTP_SIZE_3000_LESS, BODY_SIZE_2000_2999, __MIME_TEXT_ONLY, RDNS_GENERIC_POOLED, HTML_00_01, HTML_00_10, BODY_SIZE_5000_LESS, RDNS_SUSP_GENERIC, RDNS_SUSP, BODY_SIZE_7000_LESS X-Junkmail-Status: score=10/50, host=c2bthomr13.btconnect.com X-Junkmail-Signature-Raw: score=unknown, refid=str=0001.0A0B0206.50431476.0048:SCFSTAT14830815,ss=1,re=-4.000,fgs=0, ip=0.0.0.0, so=2011-07-25 19:15:43, dmn=2011-05-27 18:58:46, mode=multiengine X-Junkmail-IWF: false Subject: Re: [PHP-DEV] Re: Are exceptions allowed in php core? From: lester@lsces.co.uk (Lester Caine) Rasmus Lerdorf wrote: > On 09/01/2012 05:44 PM, Gustavo Lopes wrote: >> More importantly, there is no other satisfactory solution (except a >> fatal error). foreach has no return value, so it has no other way to >> signal a failure. If we used a notice or a warning here what would >> happen is that code that used generators with an invalid state would, >> except for the notice, work as if it had been given an empty iterator. >> Put another way, it would fail with only a notice, and continue. That is >> a far more serious problem. In other circumstances where we emit >> warnings, we usually have a return value the caller can check for error >> conditions. > > This is the real question here. It actually isn't about Exceptions at > all. It is whether trying to iterate a closed generator should be a > fatal error that breaks script execution right then and there. Whether > that is done as an exception or a fatal error isn't actually all that > relevant since the end result will be the same for most people. If > everyone is in agreement that this should be a fatal error (I don't > personally get why it has to be fatal) then lets just make it a fatal > error and when we come up with a decent proposal for turning recoverable > fatals into exceptions language-wide we can revisit this. And this might > even be in the same release, so... Finally I'm understanding what my problem is with a lot of this stuff. I kept looking at this and trying to understand exactly WHAT the flow through the code is. The 'magic' processing of generators is hiding away exactly where the source of a problem is. Showing me the code that is carrying out the processing, rewind, next etc ... at lease allows me to understand just what is throwing a problem when it happens - and handling the error! And yes an exception that gives a accurate error report is the only way of handling that without the visible code steps to error against? So we are back to the fundamental problem of how does one HANDLE that exception in an environment where they are currently only used in limited specific actions ... which may also be wrong! ... I prefer to code for and capture errors, so if the file does not exist I check for that and give the user a suitable warning. If I'm iterating a file and the read does not complete becuase of an OS read fault I like to capture that state and handle it. I can accept generators IF I can bail out with a suitable error when I need to, but exceptions are there simply because no one bothered to handle the real error? The work flow has been so screwed up that the only way out is to crash? -- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk