Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123890 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 2009C1ADA94 for ; Wed, 26 Jun 2024 20:27:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719433741; bh=QY1uDwcysTPT5EUqAbJVGk1r1ZUU7SNTZez/8uBuSVI=; h=In-Reply-To:References:Date:From:To:Subject:From; b=jOozg85T+NnwZ6/FZVXApxFYnh0luP6lmgPaFOnavpCGcjFGzTFQPcAIcO0nSRzRg 1QdGNpJfP0qKBiJW/iT6tPUviYlKhBMNU6xSYCHiokxIUlvimhgTwAIfIwhhLkL3UK l/jtMcmurouOq447Hj2DoJhPHWneN8OS9/w/lJIsEAMEQXKqs67LCLoQlV+9OMkjiB IUi8MekPej4BJ+gyrFa3PmeiRsND06/W9ZhZo6FkoLyLxp2xbi4eZAga7Yo9M+XI1z u46USaGtoaNNkuTedjuXb6XzL0cwCSMuzngYjP2U88euQaAioSXRQZJvmVfOHhSGO8 KqozlhrukiG4A== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A1B761806CB for ; Wed, 26 Jun 2024 20:28:58 +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=-0.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from fhigh1-smtp.messagingengine.com (fhigh1-smtp.messagingengine.com [103.168.172.152]) (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 ; Wed, 26 Jun 2024 20:28:55 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 43952114014B for ; Wed, 26 Jun 2024 16:27:37 -0400 (EDT) Received: from imap49 ([10.202.2.99]) by compute1.internal (MEProxy); Wed, 26 Jun 2024 16:27:37 -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=1719433657; x=1719520057; bh=QY1uDwcysT PT5EUqAbJVGk1r1ZUU7SNTZez/8uBuSVI=; b=ErVcmoIO0Ubs7g+yXHLu4abQr1 yP9bgKcEr+DO+K/iecnsPnltk+pcLs3BsTNLlmSq4GCXjzbXTJc//Kb/472WwKpy 4HFCzIIKX2dinmSYEgiCyUfWYU5tPvKil5VqLPlJpLSPG65/72nWQjF2+S+tQHmR 15hFZDdR7kOSBM1fn/JofaDMH0AgEzsjZdnghqhairtxYKHxMjUZi25neAjyZej7 +W8R5g4iKXkdgoAmf9Bwiunwy31NBuiP7l6oHcqWfq/MmL+XCPMZm4YnBFVrEnu6 sVtP29QNOBNSiTx+RZqE/P9ubY7lTT85do/J/qrIDQUYIXnHZ9xnkIiV/5yA== 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-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1719433657; x=1719520057; bh=QY1uDwcysTPT5EUqAbJVGk1r1ZUU 7SNTZez/8uBuSVI=; b=pw788s12ZfSxl33AWr2kyryQUjL68UnIMHGEF3cwiDFj JJx/113hzcBEIdjLHSoyqypTra96DBJe4FttOybPqERf4QwkPngCttHWvKa5Tnr/ nIOnUnI1RhtR10wlIekBsZMZ5HGUCwngxij5tu3B/I+8oJaEQLfBx2sjFOgzmKwM db1Tb6z52V2ZfUylkmMI8eLEl+2AOluYaxePncEkB8Co0z4DniYec8HcFT7XuEmV BF2bvb9x36N81ltDui7HUnV+lpkkloIs9tI1Acmr5oX1gCbtTAiewNoFgGIs1eeD AiWFQoz+kDOvaA55c3ocplg4J/usPBCZBVSimlNB4w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrtddvgdduheduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfgjfhffhffvufgtsegrtd erreerreejnecuhfhrohhmpedftfhosgcunfgrnhguvghrshdfuceorhhosgessghothht lhgvugdrtghouggvsheqnecuggftrfgrthhtvghrnhepfeefudfhudduieekkedugffhud fgleejgfekgefhvdeikeelvddvjeehteegteegnecuvehluhhsthgvrhfuihiivgeptden ucfrrghrrghmpehmrghilhhfrhhomheprhhosgessghothhtlhgvugdrtghouggvsh X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id E638715A0092; Wed, 26 Jun 2024 16:27:36 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-538-g1508afaa2-fm-20240616.001-g1508afaa Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: <8498ecf7-f431-4d68-aaf1-dc4cfb00241b@app.fastmail.com> In-Reply-To: References: <2a6b92eb-d5e9-4a1a-9548-a068ac42ebd2@app.fastmail.com> <1E295280-619B-4490-B53C-0899B64F9215@chaz.works> <97a93ae2-5202-47eb-bf51-ec1e976ea765@app.fastmail.com> <78D0FFF7-3867-4D71-B0C0-FA23E5121C39@rwec.co.uk> <10390963-0c2c-441a-bcce-20a0433948c5@app.fastmail.com> Date: Wed, 26 Jun 2024 22:25:50 +0200 To: internals@lists.php.net Subject: Re: [PHP-DEV] [Early Feedback] Pattern matching Content-Type: multipart/alternative; boundary=802228c53fd7460ba12154fd9f20d273 From: rob@bottled.codes ("Rob Landers") --802228c53fd7460ba12154fd9f20d273 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable On Wed, Jun 26, 2024, at 21:50, Morgan wrote: > On 2024-06-26 09:58, Rob Landers wrote: > > On Tue, Jun 25, 2024, at 23:10, Rowan Tommins [IMSoP] wrote: > >> > >> > >> It may be questionable to give meaning to the difference in some of=20 > >> these cases, but different it definitely is. > >=20 > > True, but I was mainly referring to what you would do after performi= ng=20 > > an 'is', in which case, you probably wouldn't be using any of those=20 > > functions, or if you needed to, then why do you need 'is'? Even with= the > >=20 > > $hasFoo =3D $arr is [?'foo' =3D> string]; > >=20 > > You still have to run array_key_exists() to determine whether the ke= y=20 > > exists, which means you likely still need to figure out a default va= lue,=20 > > and null-coalesce is perfect for that ... but then it just points ou= t=20 > > that it isn't that useful of a check, and that it is inconsistent wi= th=20 > > itself. > >=20 > So the issue has nothing to do with this hypothetical infinity of=20 > unobservable nulls, and comes entirely down to the fact that with this=20 > pattern a variable may pass > a) because it does not have a key named 'foo', or > b) because it has a key named 'foo' with a string value. I think this will be my last email on the subject because it=E2=80=99s l= ike talking to a brick wall.=20 There=E2=80=99s nothing hypothetical about it.=20 while(true) var_dump([][random_int()]); >=20 > In other words, "this key is optional, but if it is defined it must=20 > match this pattern". Seriously, write out using it both ways. I asked in the beginning for so= meone to give a realistic example showing a practical difference in the = final implementation and I haven=E2=80=99t seen one. I will gracefully e= at my hat. The main issue is that key-existence-check is logically incon= sistent with itself (if you say the key shouldn=E2=80=99t exist or be a = string, you=E2=80=99d be surprised to get null from that key!) And with that, I bid adieu to this topic.=20 >=20 > On its lonesome, that doesn't look very useful, but I expect it would = be=20 > one component of a larger pattern (such as "['bar' =3D> string, ?'foo'= =3D>=20 > string, ...]"). Rather than (near-)duplicate blocks for "it does not=20 > have the key" and "it has the key and it holds a string", there can be=20 > one block (which might or might not care about the distinction). >=20 =E2=80=94 Rob --802228c53fd7460ba12154fd9f20d273 Content-Type: text/html;charset=utf-8 Content-Transfer-Encoding: quoted-printable
On Wed, Jun 26,= 2024, at 21:50, Morgan wrote:
On 2024-06-26 09:58, Rob Landers wrote:
> On Tue, Jun 25, 2024, at 23:10, Rowan Tommins [IMSoP] wrote:
<= /div>
>>
>>
>> It may = be questionable to give meaning to the difference in some of 
>> these cases, but different it definitely is.
=

> True, but I was mainly referring to w= hat you would do after performing 
> an 'is', in w= hich case, you probably wouldn't be using any of those 
> functions, or if you needed to, then why do you need 'is'? Even = with the

> $hasFoo =3D $arr is= [?'foo' =3D> string];

> Yo= u still have to run array_key_exists() to determine whether the key = ;
> exists, which means you likely still need to figure= out a default value, 
> and null-coalesce is perf= ect for that ... but then it just points out 
> th= at it isn't that useful of a check, and that it is inconsistent with&nbs= p;
> itself.

So = the issue has nothing to do with this hypothetical infinity of 
=
unobservable nulls, and comes entirely down to the fact that = with this 
pattern a variable may pass
= a) because it does not have a key named 'foo', or
b) becau= se it has a key named 'foo' with a string value.
<= div>
I think this will be my last email on the subject bec= ause it=E2=80=99s like talking to a brick wall. 

=
There=E2=80=99s nothing hypothetical about it. 

while(true) var_dump([][random_int()]);


In other words, "this key is optional, but if it is defined it m= ust 
match this pattern".
=
Seriously, write out using it both ways. I asked in the b= eginning for someone to give a realistic example showing a practical dif= ference in the final implementation and I haven=E2=80=99t seen one. I wi= ll gracefully eat my hat. The main issue is that key-existence-check is = logically inconsistent with itself (if you say the key shouldn=E2=80=99t= exist or be a string, you=E2=80=99d be surprised to get null from that = key!)

And with that, I bid adieu to this to= pic. 


On its lonesome, that doesn't look very us= eful, but I expect it would be 
one component of a la= rger pattern (such as "['bar' =3D> string, ?'foo' =3D> 
string, ...]"). Rather than (near-)duplicate blocks for "it doe= s not 
have the key" and "it has the key and it holds= a string", there can be 
one block (which might or m= ight not care about the distinction).


=E2=80=94 Rob
--802228c53fd7460ba12154fd9f20d273--