Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129513 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 404FB1A00CD for ; Tue, 2 Dec 2025 20:00:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1764705662; bh=YM04jH+xE4QyV25ZAIK6nFpwH0Zhx3jeUNJem6T3YWw=; h=Date:From:To:In-Reply-To:References:Subject:From; b=WuM2DiMIy3sPJk3OKu1h81jWg0WA6Jr6ZeaYx5+6dSdarS53df3hkOa5E0ABNI/Mz X+dEiFxVRRkfNHwSRRIgiZ5sUwI+Ac9AnmNrBHRFAPXpEH5+voTJqnj52J47pWobKZ sJ0sZ66tf1Cv8ushmXpyVRtCdTm/HOq+v/ZEuq8uvXjwN4/TjVCVW5YqIzmwOmgzsT +VjLe8JsK9LaiQ1emkr/p2rjPk5gUP44nI2Zv8aVQwZfk62yO8g65gZIJzQk5BKUwG ugnID8Jzsx12kCfBcprgfIz91DAZAaMtxunnW5UiXMCT1uPg/ZOGj0e/91Vldvf431 pMe27bdMCV+rg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3D6B61804A8 for ; Tue, 2 Dec 2025 20:01:01 +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.9 required=5.0 tests=BAYES_40,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.1 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 ; Tue, 2 Dec 2025 20:00:58 +0000 (UTC) Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.phl.internal (Postfix) with ESMTP id 70427EC05BC for ; Tue, 2 Dec 2025 15:00:53 -0500 (EST) Received: from phl-imap-01 ([10.202.2.91]) by phl-compute-04.internal (MEProxy); Tue, 02 Dec 2025 15:00:53 -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=fm1; t=1764705653; x=1764792053; bh=wEyfHMjoQt8V8ewPl4gVA AHOnFatK0q6zFCzk3TG3mQ=; b=RVFCt/kYAM0ebfp6VHa0pQbFKkAPJUHz4KJRl LyPGl4JCMzc6wRsm0ruMmImVx4lzjBO3LTW2KTrs1wS5zpkgxhVlkyV8sZXG7bvn NUaMMwC7/M+kzGbGHEM4JDTECieOa0EDclVeHr6zhM//Kv/8NTUrq5yOMBXkllBv Pgawz8fJaZQUywh1cqpsqG/A2OgYoOfHY7PylmjuIqw+fH6tbjfucAR45VulVWvZ 5rzjZmBNi+OGrHij4DWXy1TWhshzh1OWTxAI3oZzAST9F6y1zTlg1/KdpKoKBCMt Szo2O/pOp7lYnQ1qm49Tj/B4FBlUG/ldteSfuUl5fwZPCG9Ag== 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=fm1; t=1764705653; x=1764792053; bh=w EyfHMjoQt8V8ewPl4gVAAHOnFatK0q6zFCzk3TG3mQ=; b=matqtVhPeScVFKEKT SzKOMAzHTWHZFYUmQ7rt2N2jJhkTsn5IzSBUHLqRVEpdecA4vcpjU77/aQVoMd1Y 5+o605po5UrchR8s92QsSPWnjR73dFgeLvkVsgfHLdAXiTE1RG9HUB/TtzX/0SaW MjemSTbrOkggT0HC5Jbey8Zi6XE3oF2AuTqXUpdEMKCxJ5rt7Hzwk9CmQ9iEY/Sx QfrGNgX+jXQLFBvqYlMtToM6TDaTvnneYhGi/eCBxgacjaZKsmejS6O0TdmHa5bt gUArg8na2HE1na9m9cZg5BioxJSBGHXm4TBPWzmzv8RXsS4sWokGGI3zVKb1jg1I kOlIA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddutddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceurghi lhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurh epofggfffhvffkjghfufgtgfesthhqredtredtjeenucfhrhhomhepfdfnrghrrhihucfi rghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmqeenuc ggtffrrghtthgvrhhnpeffieeivdfhvdeguddttdegteeiueegvefhteehfeeffeetudei tdehtdegjeeuieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomhdpnhgspghrtghpthht ohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepihhnthgvrhhnrghlsheslh hishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 240BF18C0066; Tue, 2 Dec 2025 15:00:53 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: A0wUJIXp2QXJ Date: Tue, 02 Dec 2025 14:00:32 -0600 To: "php internals" Message-ID: <3b5b8394-fc68-48ff-abc9-c0e8f261fb46@app.fastmail.com> In-Reply-To: References: Subject: Re: [PHP-DEV] [RFC] Pattern Matching Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Tue, Dec 2, 2025, at 12:26 AM, Dmitry Derepko wrote: > Thank you for the RFC and that you included option with match and=20 > individual IS=E2=80=99s, I think it would be preferable option not to = break the=20 > match construction.=20 > > Regarding the patterns, is there a way to declare and reuse the=20 > patterns? Assign it to a variable and use it as =E2=80=9Cis $pattern=E2= =80=9D or=20 > something like that. Maybe as a separate class =E2=80=9C$pattern->matc= h($var)=E2=80=9D.=20 > While it=E2=80=99s not reusable it looks like it has a limited scope t= o use it,=20 > otherwise regular replacements preferred.=20 Not currently, no. It's something we've discussed, but it's also kinda = hard, and I don't believe any other languages do it. What you could do is just wrap it in a short closure. $pattern =3D fn($x) =3D> $x is some|Pattern|null; $pattern($something); I'd love to have a way to shorten that, but so far we haven't come up wi= th one. Suggestions welcome, as I'd love to be able to do something lik= e this (obviously not exactly this): $filtered =3D array_filter($arr, is Point(x: <10)); --Larry Garfield