Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127073 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 40BD91A00BC for ; Tue, 8 Apr 2025 16:54:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1744131129; bh=iWUL6AJG07Dy+iK8tJ5KhH48ZMQhmWq2nLbaPebMslM=; h=Date:From:To:In-Reply-To:References:Subject:From; b=mmInXCK3LvYYK8LPyvkukiPWesi3E+YZXMyyoXLHDiYdbILoDgap9qxDI0E+risYv XL7xFF2WuYRtOxdFtbyRREiBdkHrxetup/qsoDuT09aB0QMfeVXznqj2LgfnvJIork xramtHuJW4dQrF5HdjKw+IJfPsU/hSqzKcw0cP2w7Km8LM6UWrpKHJP4Jgn94HLrPo eIm65398wUQuSO713BD7rhQWJDSfVDUf0ThZiaaikZOkAH1KBV0HunXCAfNwYOe7IL jwQo54C8j5FqxXjMePF3Nm6Ra3jcluK7s9B0R2jE0q9+UuGKuUmqvovtK662CV5upD f0wFFHTHhQd0Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 99E91180080 for ; Tue, 8 Apr 2025 16:52:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fhigh-b8-smtp.messagingengine.com (fhigh-b8-smtp.messagingengine.com [202.12.124.159]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 8 Apr 2025 16:52:08 +0000 (UTC) Received: from phl-compute-12.internal (phl-compute-12.phl.internal [10.202.2.52]) by mailfhigh.stl.internal (Postfix) with ESMTP id 5CDE2254018B; Tue, 8 Apr 2025 12:54:32 -0400 (EDT) Received: from phl-imap-09 ([10.202.2.99]) by phl-compute-12.internal (MEProxy); Tue, 08 Apr 2025 12:54:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1744131272; x=1744217672; bh=iWUL6AJG07 Dy+iK8tJ5KhH48ZMQhmWq2nLbaPebMslM=; b=1SjXuUhngRV26te1+kvs5spqip mvTTIFwF5qXgLtWWQckrKw9GDs0sH9fcCpGZ551x7CQcbLyi2U6xCTcHOnH0AqZd qaDZ78WxCFEwI5qtAXJugQrQmONpzhWQUN6L/wttvh9zCbjtc1U2tforffNY7HCT 1K9DNC1KHG2Fr5XAwKHlQYlxEUt8svEfEFhrbPWSmyMdkChA9Go0D599BZV18M1S Aa8J9Fn9Q0FsbpFBd/ytthMy/Ws9MQZXkiTLCGon5KDYBlZCYa4mAm/6y9MColqZ KHvTaDkCMG+EQTU1hkLZMnI2rKpqlqiPjM5jzlr1f+/C5pJKPd3+PY6h48MA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1744131272; x=1744217672; bh=iWUL6AJG07Dy+iK8tJ5KhH48ZMQhmWq2nLb aPebMslM=; b=F9NJuj7/fm20lMQ8z+J8uC7BZHfKdxJqF+M82U/nKBDKRwneVeS upZBNOZRj6URIe/0rmeAnuAVlikPi2rLyMbh5Rz2CmaNSocGK2X89vqEjLjD6VtM /Ia3AM+rRcB1dg8F6iLoxHrrR6l1E0gkWsgKULBvRSjIhK7/ax5MmN4CW3iAcD2+ DCC5VUXvpDbnpkkBxjDaRT3qdf9WycPqQU7qCI0DUPI5puPzW+YS3GSCnIuo6Lzi FBbA2mAUeiE+mWpNwEA/5PbSW46O1LkMF6GjRfLM2eqU1uOOkmDEc3gvnrmYJOP2 xuYG082XbgjSahhX3/YOGNsMvPU2k7/D/tw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvtdefieefucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpih gvnhhtshculddquddttddmnecujfgurhepofggfffhvffkjghfufgtsegrtderreertdej necuhfhrohhmpedftfhosgcunfgrnhguvghrshdfuceorhhosgessghothhtlhgvugdrtg houggvsheqnecuggftrfgrthhtvghrnhepleekhedtgfefhfelieelgfegiefhkedvleef jedtffelhfehheffgfduteduuddtnecuffhomhgrihhnpehphhhprdhnvghtnecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprhhosgessghothht lhgvugdrtghouggvshdpnhgspghrtghpthhtohepfedpmhhouggvpehsmhhtphhouhhtpd hrtghpthhtohepfigvsghmrghsthgvrhesuggrihhkrghrrghsrdhlthdprhgtphhtthho peguohhsshgthhgvrdhnihgvlhhssehgmhgrihhlrdgtohhmpdhrtghpthhtohepihhnth gvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id B887A780069; Tue, 8 Apr 2025 12:54:31 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: T120b6001cefc839d Date: Tue, 08 Apr 2025 18:54:11 +0200 To: Daikaras , "Niels Dossche" , "PHP internals" Message-ID: <8071593a-6c6d-4019-b0ab-733207e6c1d1@app.fastmail.com> In-Reply-To: References: <51fcec92-b2ae-482e-920f-c6c991b526c5@gmail.com> Subject: Re: [PHP-DEV] [RFC] [Discussion] array_first() and array_last() Content-Type: multipart/alternative; boundary=cd0249bf901f4384958ffb223aa472d0 From: rob@bottled.codes ("Rob Landers") --cd0249bf901f4384958ffb223aa472d0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Tue, Apr 8, 2025, at 10:53, Daikaras wrote: > On 4/5/2025 6:51 PM, Niels Dossche wrote: > > Hi internals > > > > I'm opening the discussion for the RFC "array_first() and array_last= ()". > > https://wiki.php.net/rfc/array_first_last > > > > Kind regards > > Niels >=20 >=20 > -1 because returning `null` for empty arrays is still wrong. Whatever=20 > similar behavior exists should be corrected to throw `ValueError` in t= he=20 > future. Just my 2c. >=20 I=E2=80=99ve always viewed arrays as an infinite field of nulls. The onl= y time this isn=E2=80=99t true is when you use array_key_exists() or car= e about the warnings (which make it less useful, IMHO). When you treat i= t as an infinite field of nulls, you get some interesting mathematical/c= omputational properties you can exploit. Trying to treat it as a map/ind= exed-array is when you start running into weird problems. =E2=80=94 Rob --cd0249bf901f4384958ffb223aa472d0 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

=
On Tue, Apr 8, 2025, at 10:53, Daikaras wrote:
<= blockquote type=3D"cite" id=3D"qt" style=3D"">
On 4/5/2025 6:51 PM, = Niels Dossche wrote:
> Hi internals
><= br>
> I'm opening the discussion for the RFC "array_first()= and array_last()".
>
> Kind regards
> Ni= els


-1 because returning `nu= ll` for empty arrays is still wrong. Whatever 
simila= r behavior exists should be corrected to throw `ValueError` in the =
future. Just my 2c.

=

I=E2=80=99ve always viewed arrays as an infinite fie= ld of nulls. The only time this isn=E2=80=99t true is when you use array= _key_exists() or care about the warnings (which make it less useful, IMH= O). When you treat it as an infinite field of nulls, you get some intere= sting mathematical/computational properties you can exploit. Trying to t= reat it as a map/indexed-array is when you start running into weird prob= lems.

=E2=80=94 Rob
--cd0249bf901f4384958ffb223aa472d0--