Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102759 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 31484 invoked from network); 11 Jul 2018 15:27:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Jul 2018 15:27:33 -0000 Authentication-Results: pb1.pair.com smtp.mail=cmbecker69@gmx.de; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=cmbecker69@gmx.de; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmx.de designates 212.227.15.15 as permitted sender) X-PHP-List-Original-Sender: cmbecker69@gmx.de X-Host-Fingerprint: 212.227.15.15 mout.gmx.net Received: from [212.227.15.15] ([212.227.15.15:44367] helo=mout.gmx.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 22/E7-15421-0E1264B5 for ; Wed, 11 Jul 2018 11:27:30 -0400 Received: from [192.168.2.101] ([79.222.41.233]) by mail.gmx.com (mrgmx002 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MAPoQ-1fnhQP2MSQ-00Bb6j; Wed, 11 Jul 2018 17:27:16 +0200 To: =?UTF-8?Q?Bj=c3=b6rn_Larsson?= , Levi Morrison , "Woortmann, Enno" Cc: =?UTF-8?Q?Pedro_Magalh=c3=a3es?= , CHU Zhaowei , PHP internals References: <13b4eb91-6566-3724-d45d-aa63254e1f58@telia.com> Message-ID: Date: Wed, 11 Jul 2018 17:27:17 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.0 MIME-Version: 1.0 In-Reply-To: <13b4eb91-6566-3724-d45d-aa63254e1f58@telia.com> Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:hqb08x4KwiOD5BS8oE4C8bY9cD9hvpKELdMfJ3+ZMgyVN1GcXXh 80PR5sy4hVqsxcthYlTSy44I906RZnui95imSiYq9xglEoCO7N6w37uxfuHKH5x73bXz/I2 BgDUyWy1OluTuCs3Hdltt5X0jUwfMUWRXaZFs3T1HwkI+CGk9lGQcOmksalZWlo5S7J4+0F wSXaY4KQGusYWdFNAaPFg== X-UI-Out-Filterresults: notjunk:1;V01:K0:Yuh1EBgu9So=:0h8zpikZNrPQQbmoOSHuS+ BpmXY30U3eLhCCF4lTaONzHztuzE9Izw7Ps4hSyh7OYv6Y6/UwE5IX84xRj+RY+o6nn3PlUsc hpUipiMsCmzPr1SL4Jc7nWbXLa6t/If878SDqRp3u844p/NAEeVGQ9qMEgOiBHHtJ0VQwhTrB AEVS9U4tX02aPxe8Y+NQtjgg1BE+3KnPwGKBVlDIbSX3DkdylknsA0aOp8fH1QMae47zGdLgT AlwoDwF6c71ckAdhWW6rThEq37b88lvYE3ogbzCcWWZeJ13FMHfeWKJX0CpLA5Qo7fNjXLheM nKs1r3WBjEwa4e+1CMwXDSjJ0n1wuhwP+RKC50GmRjO40jbijB4Jn3Zv8Wo9iy7Zf9ombviIQ lVNIUt5LzySPdWXAEsUl0aI64A3/OyAQuCj5nnLxs797FhebYjRVu49k4pO4VIzb2YveDAQAy P/on8kwvAkYFV/DyMRS5nuzqe56owxTg9ORtlwuKtjE4l1QQ5IfGlYmeRjlX90wYgzs2JS0xT jGO/A1XwfyYiorwZnRtAnPu7CVD+dIxzpf9e6HzSxDVh+AcqczrH0RxfRKCl/RRGMM+6vF+zR abkcXx1Vj0LTsOBSBbvy3mZhaT4HMz7UanJt5wWkODX3/k+ZCwcnctEyc+X6KbXVadwmbhmmc yN8hschF7OITf+fyOtQM21eZ5xY8glpuOsOcrZmJXxTeSt6+ng+MM51SMl9/YOHOsAfROxO+n 0E0REcxC4Q+Imn0g1oevB7VvyaeLt3MnUH9TUIRgkdzCw34k7VMXFpgF3SojAFeVupHijsK0+ 8RRjKPP Subject: Re: [PHP-DEV] Re:[PHP-DEV] [VOTE] array_key_first(),array_key_last(), array_value_first(),array_value_last() From: cmbecker69@gmx.de ("Christoph M. Becker") On 11.07.2018 at 17:19, Björn Larsson wrote: > Den 2018-07-11 kl. 02:41, skrev Levi Morrison: > >> On Tue, Jul 10, 2018 at 12:59 PM Pedro Magalhães wrote: >> >>> On Mon, Jul 9, 2018 at 6:31 PM CHU Zhaowei wrote: >>> >>>> I don't think we have an agreement on dealing with non-existing >>>> value, and >>>> the way this RFC proposed, just returning null without any >>>> notice/warning, >>>> is wrong IMO. I know we already do this in other array_* functions, >>>> but we >>>> cannot keep making mistakes just because we already made same mistake. >>>> >>> I voted no for the same reason. I'd even say that introducing a new >>> array_ >>> function that still accepts non arrays just to return null with a >>> warning >>> doesn't make sense at this point. >>> >>> With that said, I'd gladly vote yes if there would be a way to >>> distinguish >>> array_value_first([]) from array_value_first([0 => null]). >>> >>> Regards, >>> Pedro >> To safely use it a call to empty or count or something needs to happen: >> >>      if (!empty($array)) { >>          $value = array_value_first($array); >>          // do something with $value >>      } >> >> This is okay, but not great. Compare that to the design that returns a >> tuple though: >> >>      if ([$_, $value] = array_first($array)) { >>          // do something with $value >>      } >> >> People who argue against the tuple because they don't like the design >> need to consider the bigger picture. The tuple way is less code, >> serves more use cases with fewer functions, and I even [implemented >> it][1]. If the array destructuring behavior seems unclear we can >> simply put an example in the manual pages for these functions -- >> problem solved. >> >> This is not how RFC feedback should be handled. I hope more people >> vote no so we can reject this do it properly. >> > I do like this approach with two functions array_first & array_last > returning > a tuple. However, voting is  underway and it looks like it will pass. > > I wonder what the RFC author (Enno W) thinks about that approach? This already has been discussed weeks ago, see . -- Christoph M. Becker