Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126288 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 E65791A00BC for ; Tue, 4 Feb 2025 21:17:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1738703674; bh=86Wdx6A/xokBrteYp1e51ReSt7k3/lh3u0F1OSJGXnU=; h=Date:From:To:In-Reply-To:References:Subject:From; b=bZdh7P1eKN4f/KJAlV1W/iUPCx+F9KkjCQESuK812yWhdz8pPQnXdYigBs7MaD1VR 1e/p+Nigbw1rKXAlC0//dmE+2PVHj6pMbHymPJPIMtaH1axIi28iOluqSySOo+wqV0 JceVjgjKqlFIi6lvb23GvBSLMKmpdCt7TzWSALwNcERif1rsNT3XX4mfxNj4A8NdIt 2bI6ZFT7cLzFQ1sP60pDvc2sZji7L+yoU/NJnPnbbAdRa1R01OTOkUNtiK/KKpc4Cb ZFUCVt59YvM98H+P7gCnSPXV5N1wg5lv6boHePGdIGiYbHVEhynbLOQBwhQhRv7uD7 pr4kMxTGHrNJQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E96D11801DE for ; Tue, 4 Feb 2025 21:14:33 +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,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fout-a1-smtp.messagingengine.com (fout-a1-smtp.messagingengine.com [103.168.172.144]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 4 Feb 2025 21:14:33 +0000 (UTC) Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfout.phl.internal (Postfix) with ESMTP id 270551380209 for ; Tue, 4 Feb 2025 16:17:19 -0500 (EST) Received: from phl-imap-06 ([10.202.2.83]) by phl-compute-01.internal (MEProxy); Tue, 04 Feb 2025 16:17:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding: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=1738703839; x=1738790239; bh=5eK8V1H5PUoypnYK18N0d GxTvQUL/9HoKzcJ65wBh48=; b=ZEWAB5lEfYbEgTFdZfMTboDu/odrhmsW5FKEq GnKyR+nz49tsWEC952KK2kJQalY5QN1urmTC7bmDT6rapFONEPzmKLPyYM+/eWXx GG6ZOTCOVBXho1amNzrzOxnHpxY+nziwX2gdw7y6km9pEqvFsIhOZpLlrEHDD8V1 pMju7Y8ZYSi3TIcru2yS2/DAlHh6LqLHcI5ukjn4HkP3rcRKixI5tuqdYVIKdcfu 7c4LgRNgJjKakVw7fK30sST2gLYz0ebcQKGJ1vO2O5Roluk/RB9Yieg1S2w33Kqi Az9UWq2g758jUu68Q5m1wfqnLWtDsZsnkp+M8jBnMNOPAK0rg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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=1738703839; x=1738790239; bh=5 eK8V1H5PUoypnYK18N0dGxTvQUL/9HoKzcJ65wBh48=; b=ZKQIAugn6NAYFgDO3 dRyxJ0ka86KWqIMpzt2B0cIlEpEi/GJMua2FPWyjUuyYk95zMpe3pVkg226FIg69 5HiT0lKR6MmVbJ6qFB35I7Z2KRq72CccgYkyaAvzR2hjPxrF5NKaOy3SVtXlNeMN tDxNvO5U++mcZwP6JAuy/UOZien6GqFAyhBXNnuFKc28pCYrqrKU3B8m/LlFR/Xv EjN5TlHk1hISR4Yxv1HT8bfS5KtlJvJj0yru83qFJdjdIgmSdvqxtZL2hk9uScfD Hpg3kZO91kbNp2vSJwVT0oxLKuT9VGQy1rgTF5y86hoiNA7za8o+//d9XqxGPVKj 113+g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvudehlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefoggffhffvkfgjfhfutgfgsehtqhertdertdej necuhfhrohhmpedfnfgrrhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfh hivghlughtvggthhdrtghomheqnecuggftrfgrthhtvghrnhepkedvvedttdfhteekgfek keeijedvheetteehgfeutdfhkefhgfelfffgieehkeetnecuffhomhgrihhnpehgihhthh husgdrtghomhdprhgvshgvrghrtghhrdhmugenucevlhhushhtvghrufhiiigvpedtnecu rfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homhdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohep ihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 767C329C0072; Tue, 4 Feb 2025 16:17:18 -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 15:16:57 -0600 To: "php internals" Message-ID: <3bb77a10-f716-4729-9bc4-4b87772598a5@app.fastmail.com> In-Reply-To: <25b1011b-b2c4-4f5c-8e83-694c59ee29eb@mabe.berlin> References: <25b1011b-b2c4-4f5c-8e83-694c59ee29eb@mabe.berlin> Subject: Re: [PHP-DEV] Pattern matching details questions Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") 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 patt= ern matching RFC, which we want to complete before proposing it official= ly in case we run into implementation challenges. >>>=20 >>> Such as these, on which we'd like feedback on how to proceed. >>> [1] https://github.com/Crell/php-rfcs/blob/master/pattern-matching/r= esearch.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 keyw= ord. 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 li= ke me who uses bitwise-and quite a bit). >>=20 >> =E2=80=94 Rob 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 "ins= tanceof Foo || instanceof Bar" to be the same. That means & and | for c= onjunctions is necessary. Also supporting "and" and "or" would technica= lly be possible, but wouldn't resolve the issue (since & would still be = needed either way) and would just add more complication, confusion, and = inconsistency. I don't think that's viable. > Is it possible to use the already added "is", like: > > $arr is ['a' =3D> $a, 'b' =3D> is $b]=20 Would that inner "is" be capturing $b, or injecting $b? It just pushes = the same question down a level, and with an LL(1) parser we cannot tell = what context we're in. (If we could, there would be no problem.) =20 > Or, to use the already known uniform variable syntax "{$var}", like: > > $arr is ['a' =3D> $a, 'b' =3D> {$b}]=20 That looks like it could be confused with a property pattern, assuming w= e end up doing that for part 1. In which case, is that "index b maps to= an object with one property, and bind that property" or "index b maps t= o an object with one property, and that property should be the value of = $b"? Or "index b maps to the value of $b"? That doesn't seem any less = confusing, for the engine or human. --Larry Garfield