Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62658 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33167 invoked from network); 2 Sep 2012 08:24:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Sep 2012 08:24:25 -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:37694] helo=smtp2.ist.utl.pt) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9A/93-17065-7B713405 for ; Sun, 02 Sep 2012 04:24:24 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp2.ist.utl.pt (Postfix) with ESMTP id 4EA3870003D6; Sun, 2 Sep 2012 09:24:20 +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 JFLikktyr174; Sun, 2 Sep 2012 09:24:20 +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 D2EF37000450; Sun, 2 Sep 2012 09:24:19 +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 86690200C812; Sun, 2 Sep 2012 09:24:18 +0100 (WEST) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: "Stas Malyshev" Cc: "Rasmus Lerdorf" , "Pierre Joye" , "PHP Internals" References: <5040DC47.8000305@ajf.me> <5040F4D9.80206@sugarcrm.com> <5042946A.80204@sugarcrm.com> <5042A7D6.7050001@lerdorf.com> <5042AFD2.5090700@sugarcrm.com> Date: Sun, 02 Sep 2012 10:24:34 +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: <5042AFD2.5090700@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 03:01:06 +0200, Stas Malyshev wrote: > For me, it behaves exactly like any other > iterator would behave if you had no more useful elements in it - > meaning, producing no elements. I do not understand why you think it > requires immediate break of the code flow and abandoning the execution > of the current function - after all, for the surrounding code the > situation where iterator has no elements is a normal situation for an > iterator, and iterating twice is indistinguishable - from the POV of the > surrounding code - from iterating an empty iterator once. Moreover, if > foreach() was supposed to have any side effects, none of these effects > would happen with empty return, so there's no danger here either. So I > believe the point that this condition requires immediate exit from the > code flow needs some explanation. Precisely. The fact that everything happens normally except for the iterator giving out an empty set is what makes this an insidious problem. The request will be fully processed, but you will have a bug that may manifest itself in a relatively safe manners (e.g. a search page giving no results) -- though that could possibly cost a business money -- or in far more destructive manners (for instance, if the iterator was to return a set of files or database entities to keep when deleting others). -- Gustavo Lopes