Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96644 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 9315 invoked from network); 30 Oct 2016 11:45:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Oct 2016 11:45:42 -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.51 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 74.125.82.51 mail-wm0-f51.google.com Received: from [74.125.82.51] ([74.125.82.51:35432] helo=mail-wm0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AE/5F-25911-56DD5185 for ; Sun, 30 Oct 2016 06:45:42 -0500 Received: by mail-wm0-f51.google.com with SMTP id e69so189095732wmg.0 for ; Sun, 30 Oct 2016 04:45:41 -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=9oPfP/6lRGqCBygAm62H1nTuov0IGzvf8K7W5S6M0xA=; b=s/cEkxAHscOWahEnkikFHi0kMw9v49iKaCeFcV4ZNDVpAjpLD8e3Qb3NfkPDMm7MbH 371vAY3aDE5DNJN5flybTIkxRRnm5/EpX6PN5u0FiAS3sEULmMXUFHFGzvPbL75GDvuM o2XGoaleGlDtx6Sblz09Jh1H65eETNhlCH8/AqiqCxfTVaqbLgDsbI0JN81bWQevsEyO vw1KwB7c+mko5OL/FB23dzqcKVDI4rqcDqUVOOmFnPBdeGdoPvUpWMn1DxoIrXXtKHw3 nGDZjTyZlj96KGrPBcVQr4/2NTqanWL6AMAYor8MgP3AehGwqRoOVkmAQivlMBfvlGb8 w7DQ== 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=9oPfP/6lRGqCBygAm62H1nTuov0IGzvf8K7W5S6M0xA=; b=YAvFSxtyiZ3FKVmp1I6+yHLvIUT4+TcVoMgvAOdRe1K0spvNUYlrw3tWLRZCDSlJGb UPVEONCH41WFlUpvBuL9G4Y0TBUI8DBRMTkfn4VqSmMSyvz+GGURUWR3279sAKl5VSOg 8QK4tIYcsgXqzeXatncy2jgrezhlmKvLjv6pZhscINLq4atWnSNdEIEskvMjAyfBwkhj hIZmf/WURiXPVXn8pwH2sAg43kL38rlLqHU6abOGV36aNU9ueREGJdl75gHUIOI7rlCk tofB0y6OIQREUbkIKCMjguymZ5Vx//OfqfjXQuKzBPvzGc+TouzT/dvAfXWCn+sJXSl5 xjZA== X-Gm-Message-State: ABUngvfXqKp0WTEvHgl+sQ6SqdM5SGg2/EHVTck5W3SajpN33hmYnwMWuM18KGUMM/MiP3sRSwri/ttBhAMXVg== X-Received: by 10.28.210.195 with SMTP id j186mr7193208wmg.30.1477827939087; Sun, 30 Oct 2016 04:45:39 -0700 (PDT) MIME-Version: 1.0 Received: by 10.80.158.8 with HTTP; Sun, 30 Oct 2016 04:45:38 -0700 (PDT) In-Reply-To: References: <44244cfd-c8ad-e0a9-4e70-380a8a8c940c@syberisle.net> Date: Sun, 30 Oct 2016 12:45:38 +0100 Message-ID: To: Rasmus Schultz Cc: Levi Morrison , David Lundgren , internals Content-Type: multipart/alternative; boundary=001a11468e14593e4d054013a159 Subject: Re: [PHP-DEV] Allow Iterator to be used with current, next, reset, key functions From: nikita.ppv@gmail.com (Nikita Popov) --001a11468e14593e4d054013a159 Content-Type: text/plain; charset=UTF-8 On Sun, Oct 30, 2016 at 12:24 PM, Rasmus Schultz wrote: > With regards to deprecating array-functions that operate on the > internal pointer - I'd like to just remind you of the fact that some > of these functions, reset() and end() in particular, are often used > not because someone cares about moving the internal pointer, but as a > means of getting the first/last items of an array. > > If the internal pointers are removed, I'd like to suggest we improve > the reset() and end() functions rather than removing them - there is > an annoyance with these two functions presently: because they operate > on the internal pointer, the force you to introduce often meaningless > intermediary variables. > > That is, for example: > > $last = end(explode(",", $comma_separated_values)); > > Doesn't work. One is forced to introduce a variable: > > $parts = explode(",", $comma_separated_values); > $last = end($parts); > > If internal pointers are removed, maybe the reset() and end() > functions could be made to actually work consistently? Whether applied > to an expression or variable. > Yeah, I've been thinking about this as well. reset() and end() do seem to be the most commonly used IAP functions -- while nobody actually cares about their effect on the IAP. The thing is, if we remove all other functions that allow users to inspect the IAP, then we can simply change reset() and end() to return the first/last element. As they would no longer actually modify the array, they would no longer accept their argument by reference, so end(explode(...)) would also become legal (and additionally, they would no longer have to do a full copy of their argument, like they currently sometimes need to do). Nikita --001a11468e14593e4d054013a159--