Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80939 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 93259 invoked from network); 21 Jan 2015 15:42:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Jan 2015 15:42:41 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.44 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 74.125.82.44 mail-wg0-f44.google.com Received: from [74.125.82.44] ([74.125.82.44:62130] helo=mail-wg0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 24/B8-49046-FE8CFB45 for ; Wed, 21 Jan 2015 10:42:40 -0500 Received: by mail-wg0-f44.google.com with SMTP id z12so6860524wgg.3 for ; Wed, 21 Jan 2015 07:42:36 -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=xJ1YnASR77/CFlv7HIfec+HC9sSztMWEnFfinETAyqQ=; b=0yxxfL1sf+6pGOnMA2vkBcREiWrsGpko1xaGYzdBiXS4qkRaB4cuiSerxr2j4Xd1Rt eBv240N3Ymf/Wea9C4j/Lkmtuyy3qjnvV2SJdG0GTpERliQOPRxjAZ6DqbaKZ9qMlZEn +bppU39AbWdcUcgyLUzs0mHBg80sTh9aIyEy54ocVM/5mIgSjd+oWbg98D57RARSctd5 nc5JYz4p50EFeiLST6/rZ1ojWQ4YIQgxuBWRD+44LBf+Zx9zUULh1L1/gA/wLfVonTL3 Y/THVPYbuq0DAx5C+HmSYET/oyv0PJv8Ssrd9p1idtkNu8eVz8t76hvS+kOxPHWhJKjM fopQ== MIME-Version: 1.0 X-Received: by 10.194.108.202 with SMTP id hm10mr85587973wjb.72.1421854956472; Wed, 21 Jan 2015 07:42:36 -0800 (PST) Received: by 10.27.10.138 with HTTP; Wed, 21 Jan 2015 07:42:36 -0800 (PST) In-Reply-To: References: <54B93AAD.6080308@gmail.com> Date: Wed, 21 Jan 2015 16:42:36 +0100 Message-ID: To: Dmitry Stogov Cc: Yasuo Ohgaki , Rowan Collins , "internals@lists.php.net" , Xinchen Hui Content-Type: multipart/alternative; boundary=089e010d8a769a5130050d2b6741 Subject: Re: [PHP-DEV] Fixing strange foreach behavior. From: nikita.ppv@gmail.com (Nikita Popov) --089e010d8a769a5130050d2b6741 Content-Type: text/plain; charset=UTF-8 On Wed, Jan 21, 2015 at 2:57 PM, Dmitry Stogov wrote: > Hi, > > Yeah, I think changing foreach behaviour in more consistent and efficient > way may make sense. > If we won't use HashTable.nInternalPointer we won't need to copy immutable > arrays. > The same for nested foreach on the same array. > We could also eliminate all the HashPosition magic introduced to keep PHP5 > behavior. > > On the other hand some apps may relay on current weird behavior. > > I remember, long time ago Nikita made some related proposal. > Nikita, could you please send a link. > > Thanks. Dmitry. > Original proposal is the patch linked at the end of https://bugs.php.net/bug.php?id=53405. However that was aimed at making external HashPosition iteration to work like the internal pointer, so we could make it fully independent while keeping most of the current behavior. I fear it would make the implementation even more complicated than it already is. For PHP 7 we have the option to alter the iteration semantics for edge cases a bit (especially interaction of iteration and changes to the array). I'll have to try out some ideas in that direction and report back. Nikita --089e010d8a769a5130050d2b6741--