Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62608 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30638 invoked from network); 31 Aug 2012 15:46:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Aug 2012 15:46:52 -0000 Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 64.22.89.133 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 64.22.89.133 oxmail.registrar-servers.com Received: from [64.22.89.133] ([64.22.89.133:51120] helo=oxmail.registrar-servers.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CF/83-09246-B6CD0405 for ; Fri, 31 Aug 2012 11:46:52 -0400 Received: from [192.168.0.200] (5ad3285b.bb.sky.com [90.211.40.91]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by oxmail.registrar-servers.com (Postfix) with ESMTPSA id 9A9A875803D; Fri, 31 Aug 2012 11:46:48 -0400 (EDT) Message-ID: <5040DC47.8000305@ajf.me> Date: Fri, 31 Aug 2012 16:46:15 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: Ferenc Kovacs CC: PHP Internals References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: Are exceptions allowed in php core? From: ajf@ajf.me (Andrew Faulds) On 31/08/12 13:47, Ferenc Kovacs wrote: > It was also mentioned in that thread that we already have a bunch of > exceptions in spl, and some of the spl features should be in the core (or > it is already in the core for example IteratorAggregate). I personally don't see why SPL is separate from core PHP, especially since it's required. Why must the core not have OO stuff, but have non-OO stuff? > Personally I think that OOP features should be allowed to throw Exceptions, > and I think that it would still in line with the our users expectations. > The only problem that I can think of is that for some stuff, we have both a > procedural and an oop API, but I'm not proposing turning everything into > Exceptions, but using them where appropriate. > Not for PHP 5.5 (if that's happening?), but for PHP 6 I think a lot of things should become exceptions. I don't think that, personally, PHP's current error handling system is sufficient for properly handling errors. I think it's fine for warnings, notices, and deprecations. It's well suited to that kind of thing, and for that it should be kept (along with completely fatal core errors, where instantiating an object is inappropriate or impossible.) And yes, I think there should be exceptions in core PHP where appropriate But for handling actual errors, e.g. being unable to open a file, or failing to initialise something, Exceptions are far better suited to the task. Especially where the error is non-fatal and you may wish to catch it and do something else (for instance, if a file didn't exist, you could create a new one, perhaps). Also, I think PHP's keep-calm-and-carry-on attitude to some errors at the moment actually makes things harder, since it will often keep going, leaving behind some NULL value, when it would be much easier to debug if it stopped since then you don't have a strange undefined application state. But that's just my opinion :) -- Andrew Faulds http://ajf.me/