Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126301 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 1DF8B1A00BC for ; Thu, 6 Feb 2025 04:56:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1738817636; bh=csf3JkudwMgg7iyo2xn/domTaM3w0/6LIVusdtecjeQ=; h=Date:From:To:In-Reply-To:References:Subject:From; b=F6bN6EisevD1Bv7or8URAw+e4VovRdESFpkCzNv5hs9FT9Vxw3puPu+SUGSaGffiv ZO/j36dvQ5XiCqBSD/bT3qeYLRf0FgcRNf6vW4vhuLu/Scl0H+TstAFVsC7/CZ8H67 GdztWfRkumWrC7zGX4uOJrj6qfLLmLaz7eANgsK5Wk6bU+rJV92/vWsrunuIjrabZ2 1soufpjpjqmnl9D1UxrSNb5QH/LslqSxp2N0/ufIxCjJsAdMIFqca35RFjnZs5UByo T/T/ICS8vtS5DkVK2toxTn2pO8v8zq1njsZHF63SHorqqzmJzeEYp/3d2X8cFR/tCx rbALuncwy1RFg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 85FB6180071 for ; Thu, 6 Feb 2025 04:53:55 +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-a4-smtp.messagingengine.com (fout-a4-smtp.messagingengine.com [103.168.172.147]) (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 ; Thu, 6 Feb 2025 04:53:54 +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 4DF0813801FF for ; Wed, 5 Feb 2025 23:56:39 -0500 (EST) Received: from phl-imap-06 ([10.202.2.83]) by phl-compute-01.internal (MEProxy); Wed, 05 Feb 2025 23:56:39 -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=1738817799; x=1738904199; bh=pAm7NCzwWU+deBM3jde+0 36sWQnq/vdirIOHZPiaScg=; b=zVtINFBv2JRrO4rtBJiBmhueyUolswszHSvav 6ScjIiCdaPsAD55+u3oEeUXdZ7o/HYpKA/jhVAjGbjz3WI6igczhbHpz83uurksY tQ5XdbZO3u4nzzm6ib2qdM5502+ey9MSn2U3lRBDCzigdtYpXwMfGcy8k1S1fuP6 rYZ5pS9EwkH7XxOa0PheyYhZHKIuQgpgsM5Ro+9IFi5skXkz5U3bHYsP2ib2UMzX NQeEe8MN7BMqOtICLmUvEZ6d1PHjbsMztgrKuUgcTS82sveb8NxR6y5GVVxaVl2Q DI7DBTc3/tXWolzRiPb3vmF0YqvDgBVm0kXdr4MzUUSQsUVPQ== 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=1738817799; x=1738904199; bh=p Am7NCzwWU+deBM3jde+036sWQnq/vdirIOHZPiaScg=; b=NZzu8ISzIXWdtAmxA s9BW1qrJf+78v06L3WJNEOvWn+2AbOQIRZYSkd4UrsXBvLsV0kACCodjfuDkgcZ2 1GYbt9NZSnBuJYtUjZJnt59ajfmREzEflPC8BxawpFgWNTG/f55dp2JqkDthD8nu CJYXNkq7UBdlMZKxoWIaWCQIM97ZXsUkhkl5BswYQwnuGcD8t6i+UJQ0Zy7UDUHb 30olOhS/h/AX+xKDg2DCIwfPuhEthnVJxsbAVw/7sZ0pzMyooFMebWimMAsK6LKA mBaxTbtTk7ObBx7ytO+eC85ADcOZNgj62a9FarZuNCs3BUOYn0P0kp1X8wRLyTrk Locyg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvheegiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefoggffhffvkfgjfhfutgfgsehtjeertdertddt necuhfhrohhmpedfnfgrrhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfh hivghlughtvggthhdrtghomheqnecuggftrfgrthhtvghrnhepudegvdelgfeugeehfeej teffudevleethfefgeejffffleegtddtveekgeekudfgnecuvehluhhsthgvrhfuihiivg eptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgv tghhrdgtohhmpdhnsggprhgtphhtthhopedupdhmohguvgepshhmthhpohhuthdprhgtph htthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id DFAFC29C0072; Wed, 5 Feb 2025 23:56:38 -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: Wed, 05 Feb 2025 22:55:44 -0600 To: "php internals" Message-ID: <98aac8cf-fb19-4bf1-9deb-1e3c450e3207@app.fastmail.com> In-Reply-To: <72a771e1-dc1e-4dcf-ab93-3566e8fb68ff@app.fastmail.com> References: <25b1011b-b2c4-4f5c-8e83-694c59ee29eb@mabe.berlin> <3bb77a10-f716-4729-9bc4-4b87772598a5@app.fastmail.com> <72a771e1-dc1e-4dcf-ab93-3566e8fb68ff@app.fastmail.com> Subject: Re: [PHP-DEV] Pattern matching details questions Content-Type: text/plain Content-Transfer-Encoding: 7bit From: larry@garfieldtech.com ("Larry Garfield") On Tue, Feb 4, 2025, at 4:30 PM, Rob Landers wrote: > On Tue, Feb 4, 2025, at 22:16, Larry Garfield wrote: >> 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 "instanceof Foo || instanceof Bar" to be the same. That means & and | for conjunctions is necessary. Also supporting "and" and "or" would technically 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. > > 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: Well, right now no one is used to it. :-) Unless they've spent a lot of time in Rust. Ilija and I have been staring at it longer than anyone else, obviously, but any new feature is, well, new. > Personally, it might be worth adding binding/setting values until a > later RFC just to reduce the complexity until people get used to it. > Right now, you (and maybe a couple of others) are probably the only > people on earth who can truly understand how the syntax actually works; > the rest of us may not _yet_ be equipped to give useful feedback. That's been suggested a few times. The challenge here is: 1. variable binding is a core part of pattern matching in basically every language that has it. The decomposition capability is the primary use case. So leaving that out gives us... basically a more compact way to chain instanceof, which isn't that impressive. 2. Variable pinning is an optional feature, most languages don't have it, but it's a nice-to-have. It would be fine to punt to later. 3. Except we really need to ensure that the syntax for variable binding doesn't cause problems for a future variable pinning feature due to syntax/parsing confusion. That means we have to do at least a large chunk of the design and trial implementation up-front to make sure we're not painting ourselves into a corner. 4. At which point, we've basically implemented pinning anyway so may as well just include it. --Larry Garfield