Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70563 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 56684 invoked from network); 9 Dec 2013 18:10:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Dec 2013 18:10:21 -0000 Authentication-Results: pb1.pair.com smtp.mail=pjsturgeon@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=pjsturgeon@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.50 as permitted sender) X-PHP-List-Original-Sender: pjsturgeon@gmail.com X-Host-Fingerprint: 209.85.215.50 mail-la0-f50.google.com Received: from [209.85.215.50] ([209.85.215.50:60036] helo=mail-la0-f50.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 71/20-55888-C8706A25 for ; Mon, 09 Dec 2013 13:10:21 -0500 Received: by mail-la0-f50.google.com with SMTP id el20so1844845lab.37 for ; Mon, 09 Dec 2013 10:10:17 -0800 (PST) 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=qw8akebIKjTzqvTi01krYddoHNcxyD45OcLLlZG6ujU=; b=RMbv4YOVGTkhvgeWinnC5FRstXa6nL8b87eGfFD83j5yzEhnFdVXEIEl5YCf9z7l+5 Ri0+UDbH7g38ZOQs5HlPjXfIJqA7Cuf6J9P7Up0rA7F/oG7Pky3mJmO5iais3BTXXBRz 5TmEgRKH2ZrOY8hX9yMpEh/0VNHf5IU/yuz5HFlR6O+A3+YapkMvAFRZ2qxG5w1aJdSu SvYP3Ra+htjVEOb9M9Uuojea0zHF1CYkMmT6g9fsCC6KfAVqkaxw/IadtTePp2kk2MWg qaTDc/TkS6XhzwmhblG7U/OfiKkeYu0voJMK9cglTyyUyhIg5kJX64UXX5SRvugqFJ8H RqaQ== MIME-Version: 1.0 X-Received: by 10.152.120.66 with SMTP id la2mr2825787lab.62.1386612617356; Mon, 09 Dec 2013 10:10:17 -0800 (PST) Received: by 10.114.64.131 with HTTP; Mon, 9 Dec 2013 10:10:17 -0800 (PST) In-Reply-To: References: <6dc040b1d4917ab616951694d3f37575@mail.gmail.com> Date: Mon, 9 Dec 2013 13:10:17 -0500 Message-ID: To: Nikita Popov Cc: Zeev Suraski , PHP internals Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] [VOTE] Allowing use of exceptions in the engine From: pjsturgeon@gmail.com (Philip Sturgeon) On Mon, Dec 9, 2013 at 11:41 AM, Nikita Popov wrote: > On Mon, Dec 9, 2013 at 5:22 PM, Zeev Suraski wrote: >> >> For me it is an argument. Instead of being able to handle these errors in >> the same way they handle all other errors, now they have to learn new >> syntax and concepts. I see no reason to change the status quo, which >> allows those who want exceptions to easily convert errors to thrown >> exceptions, into a state where those who don't want to use exceptions are >> forced to use them. Again, it's entirely fair that we disagree... > > > You can't convert fatal errors to exceptions using an error handler. That's > why I'm targeting fatal errors here and not all errors in general. While I'm > not a big fan of PHP's error system in general, it's easy enough to turn > warnings or notices into exceptions via error handlers. But for fatal errors > that's just not possible. > > To achieve what I want it would be enough to turn fatal errors into > recoverable fatal errors, that would already allow the error handler > approach. But that's a lot harder to do (and imho less usable) than directly > using exceptions. Keeping the engine stable after an exceptions is > relatively simple, the same can't be said about recoverable fatals. > > Regarding the "forcing OO concepts": As Philip pointed out, unless you > already make use of try/catch a fatal error and an uncaught exception are > about the same to the end user - actually, an uncaught exception is just a > special fatal error. I could totally understand your concerns - if this > discussion weren't about fatal errors. E.g. changing a warning to an > exception would cause lots of issues. The @ operator would stop working and > people would be forced to use try/catch. But for fatals @ never worked in > the first place. You can't handle them right now. Changing them to > exceptions adds the ability to handle them via try/catch, but of course you > don't need to do them. You can let them bubble (and in most cases that's > what you should do) and let them effectively act the same way as a fatal > error currently does, just with a bit of a different message ;) > > Thanks, > Nikita Right. Put simply: 1. Users who previously did not care about exceptions will continue to not care about exceptions, and do not have to do anything any differently. 2. Users who want to handle fatal errors somehow (because you currently cannot) can use this to catch them. Nobody needs to work with exceptions if they dont want to, that fatal error just shows up as a uncaught backtrace and fatals errors just like it used to. Seems like a win win.