Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:46537 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10281 invoked from network); 28 Dec 2009 04:10:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Dec 2009 04:10:37 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@lerdorf.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@lerdorf.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lerdorf.com from 209.85.210.192 cause and error) X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 209.85.210.192 mail-yx0-f192.google.com Received: from [209.85.210.192] ([209.85.210.192:47036] helo=mail-yx0-f192.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 37/63-26502-CBF283B4 for ; Sun, 27 Dec 2009 23:10:37 -0500 Received: by yxe30 with SMTP id 30so11463467yxe.29 for ; Sun, 27 Dec 2009 20:10:34 -0800 (PST) Received: by 10.150.80.16 with SMTP id d16mr22131037ybb.0.1261973434531; Sun, 27 Dec 2009 20:10:34 -0800 (PST) Received: from ?192.168.200.22? (c-98-234-184-167.hsd1.ca.comcast.net [98.234.184.167]) by mx.google.com with ESMTPS id 8sm4589300yxg.24.2009.12.27.20.10.32 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 27 Dec 2009 20:10:33 -0800 (PST) Message-ID: <4B382FB7.9080304@lerdorf.com> Date: Sun, 27 Dec 2009 20:10:31 -0800 User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: jvlad CC: internals@lists.php.net References: <31.35.26502.C79573B4@pb1.pair.com> <1B.86.26502.42B673B4@pb1.pair.com> <4B3785AC.2000507@lerdorf.com> <8A.91.26502.CDB083B4@pb1.pair.com> <4B38106C.2080806@lerdorf.com> In-Reply-To: X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Unsetting loop variables at the end of the loop From: rasmus@lerdorf.com (Rasmus Lerdorf) jvlad wrote: >> $a = array(1); >> $b = 0; >> $c = &$b; >> foreach($a as $c); >> Now you are arguing that $b should not be 1? >> The two pieces of code are identical > > It's just a nightmare example. I wonder have you ever see anything like this > in real life? > Could you please let me see it too, for example in code.google.com? > If you cann't, what are you fighting for? > Interestingly, how many people will consider the code sample you > demonstrated ugly... > How many sporadic problems were already created and will be created just > beacause > of this unclear behavior of foreach? It isn't unclear. It is perfectly consistent. Whether it is ugly or not is irrelevant. >> And I don't see how your prev/next stuff has anything to do with this. > > > Ok. What my stuff has to do with this is there: > If prev/next were consistent with foreach, they would return first/last > element of the > array respectively as soon as they reached the boundary. But no! They return > FALSE. Which has nothing to do with the question at hand here. We are talking about breaking any reference in the variables used in the loop construct. We are not talking about any other behaviour here. -Rasmus