Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129494 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 709DE1A00BC for ; Mon, 1 Dec 2025 22:21:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1764627704; bh=yt/X4Oa+kjiEGFjZaWi7SCRRCXBADs7dxdP/yGdz4Gc=; h=Date:From:To:In-Reply-To:References:Subject:From; b=HhPWOd57U8cC0Iapg/AncS+jDQN6faUAI8nK10SHdoc1/+PsY5thZl6IGaUhM+JYo nInEsslvWLNZABqoBMEwBCbSqSQ24dEkb7Lpez6m/IXgzs7xYFw+x0CuwLxfucPmcw uBsgSNxuBNxJxHnL4aCyDcVxSXBhaU2TyH2zpe+cA/pZxipRnrNUWJuFjHTRrJUjiV 9MSYjQcxLEYNzXtHhrtk7vo0nV2baBCzfvtcZBJ36Mlf+aMLmKnDmRT1OQmrz+H6Qc th3+ZfxTzqYa1xjfkgSEFCn04M2Dib9Qv5gLTC4ajj8rF9Ls8EDA8yRBDudtRhLSMA A8lo5YUxQYRMw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D8889180339 for ; Mon, 1 Dec 2025 22:21:42 +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.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.1 X-Spam-Virus: No X-Envelope-From: Received: from fhigh-b7-smtp.messagingengine.com (fhigh-b7-smtp.messagingengine.com [202.12.124.158]) (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 ; Mon, 1 Dec 2025 22:21:40 +0000 (UTC) Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.stl.internal (Postfix) with ESMTP id C84E27A0100 for ; Mon, 1 Dec 2025 17:21:35 -0500 (EST) Received: from phl-imap-01 ([10.202.2.91]) by phl-compute-04.internal (MEProxy); Mon, 01 Dec 2025 17:21:35 -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=1764627695; x=1764714095; bh=Xq4JjMmAGOWCPqcrsJn5W cJGwCCwOeqCLE6uI40ZAEU=; b=gLGMwhOOAFY/eKVTug+zY6Ux/xZiUQ+QEefh3 L+w1eX1PagzCRIyE4SVJVI1BY7749uTYqQg03z6mAxHl7qTmFVENKzyLVdYBNMm7 vm1Zo+3FHvJHkZfcRxz9vBPBd7UE0sYyDrbhIBv2A5otziyh7eQWyTtLHh18a3xM DbiBddS0GmmSG5cBOPhWcOArYiVRTFBWcgKlo0Yij6VyCgQhdrTKQd0SE3ilAy/U A/O1n5Uqwlv9R8ulJc1RL24YS5XfKXRThppGPZ7xbRiW6ELiiGBKza3SEzrJsuDp D2aUz/rQ9UkQ+lav49wdowE8woUvvbmaiSljrgc4PS9UQSbXA== 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=1764627695; x=1764714095; bh=X q4JjMmAGOWCPqcrsJn5WcJGwCCwOeqCLE6uI40ZAEU=; b=gygiYqFfQFm312vKf T048S9tbTH8DhR1YaHAYisEbzjAsbXafNINjEEykqI+Tfy42lJp8/wP27DAqCUcb 6V8gdGPLbKzAwfq500IXJhMpS8CPkVAY2SiQKI/L+zY1zf1AB1T9jk2+rqB3wQcd jAjLjxBn78EzGyhfn5ZIlZJIg42Op/HYPYrH5FjCrjm0aOQZmwkLkcfBsR34Svrw b8F1VKzvheWuyAgw5bE1CZ5wBacGJjhuIqksgvCD6DJ2C38ZvMf2HohfD9K5ULNY l27ImJ2Xw9lk7c99sZIwSgpPNWcEdxfvLEX4BBV2lQlAPO+yQgjVAW+pqBJXOPD7 2Evig== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddvheekkeelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepofggfffhvffkjghfufgtgfesthhqredtredtjeenucfhrhhomhepfdfnrghrrhih ucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmqe enucggtffrrghtthgvrhhnpeeugfetieejueevffdulefhhfethfekvedtueevgfffvdef iedvtefgheevteelffenucffohhmrghinhepphhhphdrnhgvthenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghl ughtvggthhdrtghomhdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpd hrtghpthhtohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 53C8218C004E; Mon, 1 Dec 2025 17:21:35 -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: Mon, 01 Dec 2025 16:21:15 -0600 To: "php internals" Message-ID: <88368059-de1b-4598-8680-7611eab043cd@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 Mon, Dec 1, 2025, at 3:57 PM, Paul Dragoonis wrote: > On Mon, Dec 1, 2025, 9:39=E2=80=AFPM Larry Garfield wrote: >> Hi folks. Ilija and I would like to present our latest RFC endeavor,= pattern matching: >>=20 >> https://wiki.php.net/rfc/pattern-matching >>=20 >> You may note the date on the RFC is from 2020. Yes, we really have h= ad this one in-progress for 5 years. :-) (Though it was inactive for ma= ny of those years, in fairness.) Pattern matching was intended as the n= ext follow up to Enums, as it's a stepping stone toward full ADT support= . However, we also feel it has enormous benefit on its own for simplify= ing complex comparisons. >>=20 >> This RFC has been through numerous iterations, including a full imple= mentation rewrite just recently that made a number of features much easi= er. We have therefore included two patterns that were previously slated= for later inclusion but turned out to be trivially easy in the new appr= oach. (Variable pinning and numeric comparison.) >>=20 >> Nonetheless, there are two outstanding questions on which we are look= ing for feedback. >>=20 >> Naturally given the timing, we will not be calling a vote until at le= ast late January, regardless of how the discussion goes. So, plenty of = time to express your support. :-) > > Hi Larry, > > Looking decent so far.=20 > > match() seems a bit clunky in current state. Is it just your code=20 > example, and you could come with another one? > > The match(true) and repeating of $somevar over and over is the clunky = part.=20 > > Normal match($somevar) .. this is clean and works like switch() so=20 > people are happy adopting it .. whereas match() and match() is, look=20 > similar but you have to use them differently ? > > Can you clarify? I think you're misinterpreting the example. The first block under "match() enhancement" is the syntax we propose to = have. The second block is what it would decompose to, aka, an explanation of w= hat it means. While you could write the second block, you really should= n't when the first block is available and better. --Larry Garfield