Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102352 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88361 invoked from network); 21 Jun 2018 16:16:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Jun 2018 16:16:56 -0000 Authentication-Results: pb1.pair.com smtp.mail=larry@garfieldtech.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=larry@garfieldtech.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain garfieldtech.com from 66.111.4.26 cause and error) X-PHP-List-Original-Sender: larry@garfieldtech.com X-Host-Fingerprint: 66.111.4.26 out2-smtp.messagingengine.com Received: from [66.111.4.26] ([66.111.4.26:38239] helo=out2-smtp.messagingengine.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 22/53-32156-87FCB2B5 for ; Thu, 21 Jun 2018 12:16:56 -0400 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id B665122156 for ; Thu, 21 Jun 2018 12:16:51 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Thu, 21 Jun 2018 12:16:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=h3ZKJYOAEgYU4WPRsVpK8XIVPeiTT i0ArQI3ft9Elu8=; b=EibVXIK8lESDvAweLHk8KzUVJ/Pg+R8YclhhJnSDLKJYh sKhmh+YvvrOgAtLE308ucw76k6MmyCI7qm+WY4gn/W/S/oN1mLLf9dKUY16bbrPJ hUWdESZMn0djuPMBFgpUjTF1RmM3izjAAIuQShebcSn1kWrrokkeao5kM2VJrD7h W71Av23Y5lnZg/sGbLuX5eF5wNbfWvKLakmUsh7PXE4qwva3PrOBe9kjSEj2Keu9 0M/kxKJE1NmkWxIGaehtafYRuRVK6jH7iz6n79pQGpJE4CMQUbbGSueqllQjGEr9 yKqcMMfQYKDxBQk6gZrMuPPHQj/ZDrlnkqY5jqaXQ== X-ME-Proxy: X-ME-Sender: Received: from vulcan.localnet (216-80-30-152.s3222.c3-0.frg-cbr1.chi-frg.il.cable.rcncustomer.com [216.80.30.152]) by mail.messagingengine.com (Postfix) with ESMTPA id 7A95FE4329 for ; Thu, 21 Jun 2018 12:16:51 -0400 (EDT) To: internals@lists.php.net Date: Thu, 21 Jun 2018 11:16:50 -0500 Message-ID: <2241856.Iz1GuBRvza@vulcan> In-Reply-To: References: <75db877c-ef0b-7d3b-48a8-9879d90352b0@web.de> <3242366.BL9MUqXe46@vulcan> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart12046405.312IWjt9G8"; micalg="pgp-sha512"; protocol="application/pgp-signature" Subject: Re: [PHP-DEV] [RFC][Under Discussion] Add functions array_key_first()and array_key_last() From: larry@garfieldtech.com (Larry Garfield) --nextPart12046405.312IWjt9G8 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" On Tuesday, June 19, 2018 9:47:01 PM CDT Levi Morrison wrote: > I don't think I'm getting all the mail I am supposed to. I hope this gets > seen. > > I propose 2 functions *only* which I believe covers the use-cases that > all 4 of these do and more, with shorter names, and the ability to > discern whether the call succeeded or not. > > list($key, $value) = array_first($input); > // $key will be null if the call failed > > list($key, $value) = array_last($input); > // $key will be null if the call failed > > I have tested it with user-land functions and seems to work as > intended in all success and failure conditions. Verification that it > works as intended with internal functions is necessary but this seems > a much better proposal to me. Can I vote "heck no" to any function that does multi-return, thus making it impossible to chain or pass directly to another function? That's an idiom that just doesn't make sense in PHP. --Larry Garfield --nextPart12046405.312IWjt9G8 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part. Content-Transfer-Encoding: 7Bit -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEE/ph/GXfY8v0YwFBp4MMKwDFxYXcFAlsrz3IACgkQ4MMKwDFx YXdr9wf/blhrqRltylKdNtX/uXwqxEa7/hPrT1mRjw56VH2a5EEKyOp0ykXg2j6R 9V8IRvWV47cyztu/fZvbKO8alck8SfT23ccfQmsiXGqv2zesr1hwMwEut7rKS6RB 37OMp1oyIGhplD94HKX16mpXzU2ErN4kex7Oig40LBkCj5gN+aCnmymbdCVnEfXv aRpLawMgK5Wo9fpr4SSMwpxs9sK9Y8nV6tO2iB9c/pcfZRkXqq9o8Np9V7JR8toA YO8sIKu29747nOwXPYY3kxeJtT3MVuqonPIiovymGYoeryX28lE5TGEK0vVS/jWF XYF6Rl5SIqm+aj0cD9H9JFn2+sfCHw== =+mWo -----END PGP SIGNATURE----- --nextPart12046405.312IWjt9G8--