Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96640 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87022 invoked from network); 30 Oct 2016 04:31:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Oct 2016 04:31:32 -0000 Authentication-Results: pb1.pair.com header.from=pierre.php@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=pierre.php@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.68 as permitted sender) X-PHP-List-Original-Sender: pierre.php@gmail.com X-Host-Fingerprint: 209.85.213.68 mail-vk0-f68.google.com Received: from [209.85.213.68] ([209.85.213.68:33280] helo=mail-vk0-f68.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 72/CC-25911-3A775185 for ; Sun, 30 Oct 2016 00:31:32 -0400 Received: by mail-vk0-f68.google.com with SMTP id d65so1372126vkg.0 for ; Sat, 29 Oct 2016 21:31:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=fXlWnRZ7V/TevvJm3UppzGQS1bts6l03FVzNSTw8cgw=; b=ohWJYKAX4WdZvdsoNG7N/S+aMZRVaXZXCUPRLgHqd2dc9y7BvTBvbEZQahuFjAKWvt Jisf7mlzB5uDfm6ntvnogtK3O8UTGy11dNG46gW6wno1X8htZ5iN5pfsHkDitnh3QoiX /HzvQU676g2nlbt65GP8o3Wch7UvDtJJ1r6WI0qkFG3SUyrS0pUQmsgwy1Z4NobhRvvt ObrF1UnLcNlNU3larpULdyu0wmqDwys6CkpadPvn82FGKRJmhKh9FSuzZwcXs4zzfzO0 ahDMWZpgvERif8wMv03TNQIqJMsRhAGr+o3QbbqX789lt6vRvhq0Y9O0Lm25YRVFLV/W oyAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=fXlWnRZ7V/TevvJm3UppzGQS1bts6l03FVzNSTw8cgw=; b=Zx1EOzk4Wgnp1/ydw/mFkcDDrx2POT0c6YCsDbvY7RHCXfhNalTBo+FjlbuHap1t8L +jeEQZpq8DvBq/5Ddqocgcl3KH8Ww1FaUmQRiBUMuT+GHIvcfDenJB/IBdJcF/qJzepT v/Ztb/nW2Z6/fn2on4yh+ZoknO1DMavoDyxQ/2TzrTmRWU1lLFjIGqFQE3RjzaliQes1 /PilCNAyBEhH0iTDCy/yurHvnK46Hsm5QIXbXl+L7QKnxFS8uZ7JfLsrl7UR7DabDIxQ fBwMdYtnjYtkO/7G4FUe15uoC8XtiAs9uuwvoKId2+AH9dHezEblpZxvZuw5Y5Gtv1wp VFdw== X-Gm-Message-State: ABUngveg34x8ckfxF5nk6ib+0CpdVoIo9gjo+Xdhn/iLMz0cQV/6Md1UFP9UwkMSCIWqyq+tc5IBVm31warZjA== X-Received: by 10.31.108.133 with SMTP id j5mr18656330vki.161.1477801888315; Sat, 29 Oct 2016 21:31:28 -0700 (PDT) MIME-Version: 1.0 Received: by 10.159.36.108 with HTTP; Sat, 29 Oct 2016 21:31:27 -0700 (PDT) In-Reply-To: References: <44244cfd-c8ad-e0a9-4e70-380a8a8c940c@syberisle.net> Date: Sun, 30 Oct 2016 11:31:27 +0700 Message-ID: To: Nikita Popov Cc: Levi Morrison , David Lundgren , internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Allow Iterator to be used with current, next, reset, key functions From: pierre.php@gmail.com (Pierre Joye) hi Nikita, On Sun, Oct 30, 2016 at 3:06 AM, Nikita Popov wrote: > On Fri, Oct 28, 2016 at 2:43 PM, Levi Morrison wrote: > >> On Wed, Oct 26, 2016 at 7:42 AM, David Lundgren >> wrote: >> > Greetings, >> > >> > As suggested by several reviewers of a PR[1] I recently submitted, I'd >> > like to get feedback on letting custom Iterators be used in the current, >> > next, reset, and key functions. If this is something to move forward >> > with, I'll need some help with the RFC process. >> > >> > Recent experiences trying to use these functions with a custom Iterator, >> > and a bug[2], led me to try and fix this. BC will occur when an object >> > implementing Iterator is passed to one of the functions, as the >> > interface methods will be called, instead of returning the objects >> > properties. The old behavior should be maintained for classes that do >> > not implement Iterator. >> > >> > [1] https://github.com/php/php-src/pull/2176 >> > [2] https://bugs.php.net/bug.php?id=49369 >> > >> > Thanks, >> > Dave >> > -- >> > David Lundgren >> > dlundgren@syberisle.net >> > 808.639.0365 >> > GPG: 0x26F54D7F >> > >> > -- >> > PHP Internals - PHP Runtime Development Mailing List >> > To unsubscribe, visit: http://www.php.net/unsub.php >> >> I can't seem to recall specifics anymore but I do believe some people >> would greatly prefer to remove the internal array pointer for >> iteration and deprecate these functions. Maybe someone else can >> remember more? Nikita and Bob, maybe? >> > > Yeah, I'm one of those people. In PHP 7 the most important user of the IAP, > foreach, was switched to use a more robust mechanism. I believe that at > this point, the concept of an internal array pointer has outlived its > usefulness and we should be working toward removing any APIs that publicly > expose it, including each and the next/current/key family of functions. I > will propose to deprecate each() in particular for PHP 7.2, because it is > both more problematic and more useless than the others, but I'd like to see > the others go away in the long term as well. If people want fine-grained > control over array iteration, they should use an external iterator (aka > ArrayIterator), not an internal one. How do iterators compare to a for/while/custom loops using next/current/etc? I did not bench it lately but last time there was a significant impact when using Iterators. I also think it is a good thing to clean up the ways to work with arrays or iterable but we have to be very careful how we do it. I am not sure an actual deprecation is a good thing in 7.x without breaking any kind of tests out there. Indeed it will not break code but it is rather bad to break tests and it is a very annoying thing to do while trying to be good at using the latest PHP version. I am not sure if a documentation+UPGRADE guide and all possible communications about such deprecations would be enough. Maybe only until we reach the last version before 8.0 (which can use actual deprecations warnings, given we have more than 7.2 before 8.0). Cheers, -- Pierre @pierrejoye | http://www.libgd.org