Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96657 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 40612 invoked from network); 30 Oct 2016 17:19:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Oct 2016 17:19:32 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.41 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.41 mail-wm0-f41.google.com Received: from [74.125.82.41] ([74.125.82.41:35059] helo=mail-wm0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9B/84-25911-1AB26185 for ; Sun, 30 Oct 2016 12:19:32 -0500 Received: by mail-wm0-f41.google.com with SMTP id e69so198309403wmg.0 for ; Sun, 30 Oct 2016 10:19:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=vXusb+9VWpcaxbdpnp17LgNT8KfzuDonmopijAXNp2g=; b=LT0VW1ytArh6hi5y6W04Ezb8UoF3WQEnvlwNvsUGD2nmOPFLq6AiRNWcohJx7xKu41 7Rl67HKyp+taXypY+la+EN3naE39CS/CU0LkTQYHn6e7Iwv/NaX5gWCcNh8YCuPjSq5X qzkRQF/8LjzKtkhCw8o2Q0/SKO4MDaAzpD0Jz8SiOcb/tNXtQW8hUgZLLOkiDrguzXkL xE18tI+saPghRSthHFAbpGudz8x1FADVMpK0KmWO0fC+3ItKnUziJiiK3R3Qt9QtMZIT fvaRYXRbHCOqjJAVfdHzlV9fhVOhP6Iyyz+E4R8CnoqaXj5OLPj849mFbcod7rwGZHnT ct/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=vXusb+9VWpcaxbdpnp17LgNT8KfzuDonmopijAXNp2g=; b=gguOipsnmZoDZjH+X1W9HWLa4hOATxPt8e+7eS3ZOpGBz3KAxT7/qd0NjTk5ZQyODx /BMDSwMJIkURR67bSBrhlExFqt+8kDiYsk6OgXaeQSWbjz+WvdfDYeblUHWbd7plWoP1 dFh56dSabldpwsYaoeeXpUufnTyCDQ9ixd87lL/ThJ52hjVqf6MvqEaHX7ESoTcQ0oix UWV0DcFUGEIdLEcIJIlMSig23YEKg9jv2piN3nKUflG0wIB4jmThwL6S+FrYDQ3ePStC KcoOvm5M/oqEWYJJ05M7szsG13MqC31yfL8/UGzxG2W2iR39JnCYpAm62VA8fi07w5pB EsEQ== X-Gm-Message-State: ABUngvfUmuZ3dqJWpLZwHn0sqvGfgIJJHFZO9IG1Ya606e/mxVmmgAL7WCIPXL6WjaT7+A== X-Received: by 10.194.147.67 with SMTP id ti3mr18713138wjb.17.1477847967121; Sun, 30 Oct 2016 10:19:27 -0700 (PDT) Received: from [192.168.1.5] ([95.148.161.240]) by smtp.googlemail.com with ESMTPSA id n3sm22049588wjq.34.2016.10.30.10.19.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 30 Oct 2016 10:19:26 -0700 (PDT) To: internals@lists.php.net References: <44244cfd-c8ad-e0a9-4e70-380a8a8c940c@syberisle.net> <01f2f3da-592b-fd23-709d-ad620422f56d@fleshgrinder.com> Message-ID: <7fb9a5d5-318d-7ed3-59eb-d9845ed5dec1@gmail.com> Date: Sun, 30 Oct 2016 17:19:24 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <01f2f3da-592b-fd23-709d-ad620422f56d@fleshgrinder.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Allow Iterator to be used with current, next, reset, key functions From: rowan.collins@gmail.com (Rowan Collins) On 30/10/2016 12:07, Fleshgrinder wrote: > I think it makes much more sense to deprecate all of them and introduce > new ones that work in the way we want them to for several reasons. > `end()` and `reset()` would have to continue working as they do until > the next major release since people who use them might rely on the way > they work. This means in effect that nobody can make her PHP 7 code PHP > 8 ready up front. > > Instead we could directly introduce `array_first()` and `array_last()` > with the next feature release -- even if the others are not deprecated > -- and everyone can update their code or at least use it in new code. I've always felt like these functions were "missing" from the language - there are a number of ways you *can* get the first or last item in an array, but all have side effects, because they're not designed for this purpose. It just so happens that - most of the time - reset() and end() have the smallest side effects. I can't remember if it was an earlier discussion here, or somewhere else, that pointed to getting the first and last *key* as an extra use case worth considering. It's currently possible (if awkward) with key(). I think it would make sense to, in the same version: - deprecate reset(), end(), each(), and key() - introduce array_first(), array_last(), array_first_key() and array_last_key() - document replacements for whatever other use cases we can find examples of Doing them all at once makes the messaging much clearer - this family of functions is going to be removed; and here are the new functions you can start using immediately instead. Regards, -- Rowan Collins [IMSoP]