Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126290 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 774071A00BC for ; Tue, 4 Feb 2025 22:32:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1738708161; bh=PvlPAzwBpFl/WSeamtscqelUAu1tdfnFfuYpPYbjuXU=; h=Date:From:To:In-Reply-To:References:Subject:From; b=J072ucD43MUbH6XyJZzL989HmdqyIIg6bfZZB9fEZ3m0SmW+5GBuHOTSqqNFhOiBo BcQBC/EyMltpEbA5jAEgBX3HxdFhHv5Y2tghT2FOgeuQbofBv6KzZp+W8VQrdkGygz 2kVSGSr+DBgpbejKbu+ho1/9rKK1qqqcqoV7SS6HJjxjRglnXTh1l1EjPdXAaZaVdt 391sFIqqRPVn2X7oNqGaJ2bNXmw9eOML0cRX9/BNpohmclcY+yNwKrqG65p4IBw3wh czEZ0i8KsbrWC8NjDssdLYgpHyH6bLAcdgI41Dx9HiKiAr/4Ubg/qq6BO99q9HmGln 5rwdBxrEmLE2Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1813B180034 for ; Tue, 4 Feb 2025 22:29:20 +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 autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fout-b5-smtp.messagingengine.com (fout-b5-smtp.messagingengine.com [202.12.124.148]) (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, 4 Feb 2025 22:29:19 +0000 (UTC) Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfout.stl.internal (Postfix) with ESMTP id E5FCB11400FA for ; Tue, 4 Feb 2025 17:32:04 -0500 (EST) Received: from phl-imap-09 ([10.202.2.99]) by phl-compute-01.internal (MEProxy); Tue, 04 Feb 2025 17:32:04 -0500 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=fm1; t=1738708324; x=1738794724; bh=VbbjCTVXjB +Efqxq0DpPjjJMzZPf8zG4Y1SL2wXXoe8=; b=H4oWIQ3NBg63P0LWa1fyU6e0zk 5nmjK51xX8tNW9X1H32+3d5Bl3OYbT6hT+GeleQ+aXBtoQHSYWm/HmoFYMmHZIh5 GbFbOGBBu3ZmCUfkTC7FKirXkbuQ1IVJ2/uFtIE+g+o4gVdtja2VyWKzBYppE95I QIhK6zx+kGJLMIq4SRjAAlfPj9/w+qdH4jcdnJwZsuxRAH2ttWrBWMr5jEWF6ym5 a9U62pYxCsyW73KdakF+BmTTQM6nIBT4woaHhlap9sgz6VOIXMOZQ+qVLpOCuOrk Ku+c0N8GoEaaUwQQnXfg2DWyN5rbuyipYjG7xPODYHlCvpwcYTelQbwSDCSg== 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=fm3; t= 1738708324; x=1738794724; bh=VbbjCTVXjB+Efqxq0DpPjjJMzZPf8zG4Y1S L2wXXoe8=; b=HwBDYSJ2bm+xaNbK3qzZs6xBhFMOnb3Ux8UD+X+0sZDCUWC+l4y xQEVx0kYZV2lrwaqWaX91pMtDQrS4xGj/TAr/ZGO5IQr0rBFpF+1CPcvteW364pm 3WMdBNsLqIDYmg95G+F3Gws/OcoqgAz97K8suKpc1/T2oBpilVxZ028fK26u/fyz qr/enNAnjRiT7RyvySCDnhZrxxis2swtHgxZN2hHFds7xT4miEhpxgU3+WQveDJT 0QOz2lmzLZY8oK8jLAQ3Vhj6LgnEmAr5M0mTEfTlVYyKlvBpFrbw2lk8zaybPTvp jZp8dZFdZMwhGnrzrwx/Va9kggObpt+PeNA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvudejhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecuogfuuhhsphgvtghtff homhgrihhnucdlgeelmdenucfjughrpefoggffhffvkfgjfhfutgesrgdtreerredtjeen ucfhrhhomhepfdftohgsucfnrghnuggvrhhsfdcuoehrohgssegsohhtthhlvggurdgtoh guvghsqeenucggtffrrghtthgvrhhnpeeghfekgeehvdehfeeigefgvedtvefgtdeivddv udfhhfdvgeelgeduudetkedugfenucffohhmrghinhepghhithhhuhgsrdgtohhmpdhrvg hsvggrrhgthhdrmhgupdefvheglhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecu rfgrrhgrmhepmhgrihhlfhhrohhmpehrohgssegsohhtthhlvggurdgtohguvghspdhnsg gprhgtphhtthhopedupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehinhhtvghr nhgrlhhssehlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 5E453780068; Tue, 4 Feb 2025 17:32:04 -0500 (EST) 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 Date: Tue, 04 Feb 2025 23:30:44 +0100 To: internals@lists.php.net Message-ID: <72a771e1-dc1e-4dcf-ab93-3566e8fb68ff@app.fastmail.com> In-Reply-To: <3bb77a10-f716-4729-9bc4-4b87772598a5@app.fastmail.com> References: <25b1011b-b2c4-4f5c-8e83-694c59ee29eb@mabe.berlin> <3bb77a10-f716-4729-9bc4-4b87772598a5@app.fastmail.com> Subject: Re: [PHP-DEV] Pattern matching details questions Content-Type: multipart/alternative; boundary=b2048aa7eb3a4fd5a09f91a7697de3aa From: rob@bottled.codes ("Rob Landers") --b2048aa7eb3a4fd5a09f91a7697de3aa Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Tue, Feb 4, 2025, at 22:16, Larry Garfield wrote: > On Tue, Feb 4, 2025, at 1:14 PM, Marc Bennewitz wrote: > > On 04.02.25 08:51, Rob Landers wrote: > >>=20 > >>=20 > >> On Tue, Feb 4, 2025, at 05:31, Larry Garfield wrote: > >>> Hi folks. Ilija is still working on the implementation for the pa= ttern matching RFC, which we want to complete before proposing it offici= ally in case we run into implementation challenges. > >>>=20 > >>> Such as these, on which we'd like feedback on how to proceed. >=20 >=20 > >>> [1] https://github.com/Crell/php-rfcs/blob/master/pattern-matching= /research.md > >>>=20 > >>> --=20 > >>> Larry Garfield > >>> larry@garfieldtech.com > >>>=20 > >>=20 > >> Hey Larry, > >>=20 > >> Instead of symbols, why not use words? > >>=20 > >> We already have &&, but it looks like this uses & instead, which is= a bitwise-and. But the language does have =E2=80=9Cand=E2=80=9D as a ke= yword. So instead of: > >>=20 > >> $value is int & &$x > >>=20 > >> It would be: > >>=20 > >> $value is int and &$x > >>=20 > >> Which removes the confusion you mentioned before (also for someone = like me who uses bitwise-and quite a bit). > >>=20 > >> =E2=80=94 Rob >=20 > Patterns are deliberately designed as a superset of existing DNF types= . You can already have a type of Foo&Bar, so we want the pattern for "i= nstanceof Foo || instanceof Bar" to be the same. That means & and | for= conjunctions is necessary. Also supporting "and" and "or" would techni= cally be possible, but wouldn't resolve the issue (since & would still b= e needed either way) and would just add more complication, confusion, an= d inconsistency. I don't think that's viable. Interesting way of looking at it, not wrong either. I guess I'm not used= to this syntax that much. It's like reading the following statement and= working out what the value is without running it: add($a =3D add($a =3D 2, $a), $a =3D add($a, $a)) + $a; To me, mixing up both setting and using values in the same statement rea= ds like above. Once you work out how it works, it makes sense that the f= irst parameter is 4 and the second is 8, with $a =3D=3D 8 and the result= being 20 (https://3v4l.org/MPb5P). It takes some getting used to, thoug= h, and only works because we intrinsically understand the parser to AST = to opcodes -- even if we don't know the details. Personally, it might be worth adding binding/setting values until a late= r RFC just to reduce the complexity until people get used to it. Right n= ow, you (and maybe a couple of others) are probably the only people on e= arth who can truly understand how the syntax actually works; the rest of= us may not _yet_ be equipped to give useful feedback. It won't stop me from trying to help, but I also don't want to waste you= r time by saying incredibly incorrect statements like using "and" instea= d of "&" to denote a type. :) =E2=80=94 Rob --b2048aa7eb3a4fd5a09f91a7697de3aa Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable