Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129925 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 lists.php.net (Postfix) with ESMTPS id 9E0351A00BC for ; Mon, 26 Jan 2026 04:47:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1769402874; bh=SBHiv1bghZzMLb1aY56U5LrhAU5+8xO5+RQi1YnVvJ4=; h=Date:Subject:To:References:From:In-Reply-To:From; b=XerjJvgoqKYKZ756Ar65odZVjf9Z8a8Iv3ApqiikUBUeKxF7GFqJ6Rqq0EmMO+nsT 6kg5uooDIJX+dnSvipHr7Bs8/YkYk11lRYcSyLHvITk+4k6a2m52BsCltEjjfYLjgI PTBYdIFctHSrJTcrdzq6weNQRuKS2kCc28L2TMamP53/kwQLzlvYQu/MqcLcGTRJhH hS1rofhM0dJ2q1f5H3FQWxGrVHHbnIGZ9su1k8rd3buq1bo28aaY40+/1yHWtVKU7m 0yr5733U6NhA/nb1IdLpMBR5Ntgi+F1teBHoZl8on/ItGBYmM7+qgQ6DnlJb+fC30P rolk6NJLARb+A== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9B77E180039 for ; Mon, 26 Jan 2026 04:47:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,DMARC_MISSING, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from jessie.smtp.mailx.hosts.net.nz (jessie.smtp.mailx.hosts.net.nz [43.245.52.195]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 26 Jan 2026 04:47:50 +0000 (UTC) Received: from 122-57-27-239-adsl.sparkbb.co.nz ([122.57.27.239] helo=[192.168.1.67]) by jessie.smtp.mailx.hosts.net.nz with esmtpsa authed as varteg.nz (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_128_GCM:128) (Exim 4.96) (envelope-from ) id 1vkEVq-002PZs-0f for internals@lists.php.net; Mon, 26 Jan 2026 17:47:42 +1300 Message-ID: <49cb415d-adb9-408d-82af-b71f6de234ad@varteg.nz> Date: Mon, 26 Jan 2026 17:47:35 +1300 Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] [RFC] Pattern Matching To: internals@lists.php.net References: <56dce794-a512-421a-a8d2-91a9692c1ab4@app.fastmail.com> <23093833-bdd2-442d-86b8-9ef492c51ad1@app.fastmail.com> Content-Language: en-GB In-Reply-To: <23093833-bdd2-442d-86b8-9ef492c51ad1@app.fastmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Hosts-DKIM-Check: none From: weedpacket@varteg.nz (Morgan) On 2026-01-26 07:44, Larry Garfield wrote: > > With per-arm, you can opt-in to pattern matching individually, at the cost of having to remember to repeat the keyword on every line. With per-block, you only have to add the keyword once at the cost of not being able to selectively use patterns or identity matching. > > Which tradeoff is better is the option question. (Ilija and I disagree on which to go with.) Or, if someone can suggest a way to allow automatic detection reliably, that would also be most welcome. :-) > If it had to be one or the other, then arms-only would be my choice as the more flexible of the two - and it's the one we have now, so the real question is if "match($foo) is {..." should be added as a shorthand for when all matching is on patterns. I'm leaning toward "yes", especially as scalar literals would pattern match by value identity anyway. Falling back on per-arm "is" would only be necessary to address those class/constant confusions if and when they arise - but when they do you'll want it to be possible to address them. But if "is" were required on every pattern match, that's a lot of "is"ing. People would get into the habit of using it like "case" in a switch statement (or putting backticks around every single identifier in a MySQL query), using it even when a value match is sufficient. And then having it bite them precisely in those cases when there is something like a class/constant confusion.