Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:77846 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49418 invoked from network); 10 Oct 2014 11:46:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Oct 2014 11:46:52 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.48 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 74.125.82.48 mail-wg0-f48.google.com Received: from [74.125.82.48] ([74.125.82.48:57404] helo=mail-wg0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 18/93-29144-A27C7345 for ; Fri, 10 Oct 2014 07:46:51 -0400 Received: by mail-wg0-f48.google.com with SMTP id k14so3627265wgh.19 for ; Fri, 10 Oct 2014 04:46:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=WhuDhbPByh8l48UEBFMqdoMd4CN67DXWuFsMDicG7K0=; b=eJ6MKnIiVD/1iThsiplR9+94HgXFUbEUTHMIh1t0SpsgBCfQevz1McQmHrUlCKlTYm 1PXsfMSczc+YbfRfPVgmwD9Kk05kkxa/myHTZnqfBR2+1KFFRnDCfHV8DSBJuy8VSH1G 1AEMCCx18tGBgaNMf3nbEYP7FIAzV0x7s1yh2CIXzzuYup/0G+7+dIvk5jqEBpA8wkWs 5XdFBmxrz7j6ZknVKBEUddktda8VKjA5gskiolmFmiJ4SKLr5WmGiyuECkgrKGQyaQla NFXHXQyOvIzlYXVr6dfd+Kltn3E5N/3qVdxHxKngqB3YP4ZZJUCTYOzM6FiTCBXkBAri KIFA== MIME-Version: 1.0 X-Received: by 10.180.102.41 with SMTP id fl9mr4211275wib.52.1412941607326; Fri, 10 Oct 2014 04:46:47 -0700 (PDT) Received: by 10.27.10.79 with HTTP; Fri, 10 Oct 2014 04:46:47 -0700 (PDT) In-Reply-To: <543320AB.4070606@sugarcrm.com> References: <543320AB.4070606@sugarcrm.com> Date: Fri, 10 Oct 2014 13:46:47 +0200 Message-ID: To: Stas Malyshev Cc: PHP internals Content-Type: multipart/alternative; boundary=f46d0444814b97da9b0505101a12 Subject: Re: [PHP-DEV] [RFC] Exceptions in the engine From: nikita.ppv@gmail.com (Nikita Popov) --f46d0444814b97da9b0505101a12 Content-Type: text/plain; charset=UTF-8 On Tue, Oct 7, 2014 at 1:07 AM, Stas Malyshev wrote: > Hi! > > > As such I'm re-proposing this RFC for inclusion in PHP 7: > > > > https://wiki.php.net/rfc/engine_exceptions_for_php7 > > > > The RFC text is essentially the same as previously, with the primary > > difference being that parse errors are now converted to exceptions as > well. > > This was previously not possible due to limitations in the compiler > design. > > I like this. Fatal errors and warnings were for a long time in different > leagues, and the need to handle them better produced E_RECOVERABLE_ERROR > which is a weird creature - like exception but not quite. I think PHP 7 > is a good time to move to exceptions for real errors (as opposed to > informational messages like E_WARNING). > > The only issue I think we need to discuss is catch(Exception $e). Now it > would catch much more than before, if we do no changes. Should we allow > it or should be have hierarchy that separates user exceptions and engine > exceptions, and have catch(Exception) catch only the former. > There is precedent in other languages for having exceptions that are not usually caught. Java has a Throwable interface, which is implemented by Exceptions and Errors, where the latter are usually not supposed to be caught. Python has a BaseException, which is extended by Exception and SystemExit, GeneratorExit and KeyboardInterrupt, where the latter three are not usually supposed to be caught. I think that the decision whether or not we wish to introduce something like this mainly depends on how we intend these EngineExceptions to be used. If they are only supposed to be caught by top-level code to enable graceful error handling (in particular for long running code) then it probably makes sense to keep them outside the main exception hierarchy. If on the other hand it's considered okay to catch them during normal program execution, they should be normal exceptions. > However, I see in the RFC it does not remove all the errors. I think we > need to strive for having all the non-core errors except for out of > memory and timeout be converted. Are there ones that are problematic to > convert or it is just the question of time/effort? > There are a number of E_ERRORs that we cannot feasibly convert to exceptions. I've analyzed this for the previous discussion and likely the numbers are still about right: http://markmail.org/message/gfdczr6zpgzynid4 So a conservative estimate is that we can turn 85% of the E_ERROR occurrences into exceptions. (This doesn't tell us anything about the percentage of actually thrown errors though.) And yes, it's also a question of time/effort. The hard part usually isn't converting to exceptions, but updating all the tests that fail because of it. I'd like to have good exception coverage by the time PHP 7 gets released, but would prefer to do the porting incrementally (these huge patches get stale very fast). Nikita --f46d0444814b97da9b0505101a12--