Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62644 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 91475 invoked from network); 2 Sep 2012 00:57:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Sep 2012 00:57:01 -0000 Authentication-Results: pb1.pair.com header.from=glopes@nebm.ist.utl.pt; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=glopes@nebm.ist.utl.pt; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain nebm.ist.utl.pt from 193.136.128.22 cause and error) X-PHP-List-Original-Sender: glopes@nebm.ist.utl.pt X-Host-Fingerprint: 193.136.128.22 smtp2.ist.utl.pt Linux 2.6 Received: from [193.136.128.22] ([193.136.128.22:35640] helo=smtp2.ist.utl.pt) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2A/3C-17065-CDEA2405 for ; Sat, 01 Sep 2012 20:57:01 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp2.ist.utl.pt (Postfix) with ESMTP id 2660A70003D3; Sun, 2 Sep 2012 01:56:57 +0100 (WEST) X-Virus-Scanned: by amavisd-new-2.6.4 (20090625) (Debian) at ist.utl.pt Received: from smtp2.ist.utl.pt ([127.0.0.1]) by localhost (smtp2.ist.utl.pt [127.0.0.1]) (amavisd-new, port 10025) with LMTP id VAfk-wiZaram; Sun, 2 Sep 2012 01:56:56 +0100 (WEST) Received: from mail2.ist.utl.pt (mail.ist.utl.pt [IPv6:2001:690:2100:1::8]) by smtp2.ist.utl.pt (Postfix) with ESMTP id C698170003CC; Sun, 2 Sep 2012 01:56:56 +0100 (WEST) Received: from damnation.nl.lo.geleia.net (unknown [IPv6:2001:470:94a2:4:21d:baff:feee:cc0b]) (Authenticated sender: ist155741) by mail2.ist.utl.pt (Postfix) with ESMTPSA id AD0AC2006C5D; Sun, 2 Sep 2012 01:56:55 +0100 (WEST) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: "Stas Malyshev" Cc: "Pierre Joye" , "PHP Internals" References: <5040DC47.8000305@ajf.me> <5040F4D9.80206@sugarcrm.com> <5042946A.80204@sugarcrm.com> <5042AA5E.8070307@sugarcrm.com> Date: Sun, 02 Sep 2012 02:57:12 +0200 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Organization: =?utf-8?Q?N=C3=BAcleo_de_Eng=2E_Biom=C3=A9di?= =?utf-8?Q?ca_do_I=2ES=2ET=2E?= Message-ID: In-Reply-To: <5042AA5E.8070307@sugarcrm.com> User-Agent: Opera Mail/12.01 (Linux) Subject: Re: [PHP-DEV] Re: Are exceptions allowed in php core? From: glopes@nebm.ist.utl.pt ("Gustavo Lopes") On Sun, 02 Sep 2012 02:37:50 +0200, Stas Malyshev wrote: >> * If users do not expect exceptions in the core, they are mistaken. >> There are indeed exceptions in the core. See ZEND_FE_RESET and >> zend_interfaces.c. Of course, no evidence has been provided one way or >> another. > > This is not right either, but that was done in 2005. We're now in 2012 > and trying to make PHP a bit more orderly. The position that we should not use *more* exceptions in the core is of course legitimate. But let's not temper with the factual record to make an argument for it. This discussion should have started with an accurate description of the current state. >> * In fact, if there is a unifying theme in the usage of exceptions in >> PHP, is that exceptions are used when OOP interfaces are involved (see >> Zend >> interfaces, SPL, DateTime and PDO -- though optional there). The core >> vs. non-core argument only looks attractive because there are few >> built-in >> classes in the core. > > That's not my argument. My argument is when you instantiate some class > explicitly and work with it, you know you're dealing with certain API > that may include exceptions. When you're using foreach(), you don't > expect to wrap each foreach() into a try-catch block. But that's what is > happening here. I'm not sure what you're saying that is not your argument. What you cite is an argument of mine, not yours. After that, you're basically saying the same thing as Derick -- that because you're not instantiating a class directly, you don't know that you're working with an object API that includes exceptions. I don't really have a argument for that except that users should know that generators return a sort of iterators. But in any case, the argument that you have to wrap foreach() in try-catch blocks is weak. That's like saying that in Java you have to try-catch IllegalStateExceptions all the time. The truth is, correct code will never throw these exceptions. As I explained in the reply to Rasmus' e-mail, a fatal error would also be somewhat appropriate (though inconsistent with the other Zend interfaces), but definitely a warning is not. -- Gustavo Lopes