Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129497 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 6332E1A00BC for ; Mon, 1 Dec 2025 23:12:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1764630780; bh=Mzvg9EaoJMxQdy0z/qhnhKEW4oSK3KVRRUU19LdJ4MU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=OQo2pNQy9bOOgUYyz7VERXttBbFYnEPL84R5i1SvePFiVY0bQqPOkwlP/vdrqKXuF s1OMLCOXKccrQnBenY7I8oMySg871qNX7yad219eKxW2erzEU2pZ5HQwMbUu0uD+ce chGHEan6I+O4TUEooBCw9ivNbpFbgw+vQGFs73d1nz0Ojj8Tqk9pUBacCcPVNAZBo7 FlWfwz1XwGvnKBfWJFe7Xh7D+jXbWist1Sfsy3JuJoN6QXaf4ZhMFpC03orFIYTfPO oNmJ3hs86rIDJhcCpnB9IPjOXBQpEGIeWV5XjUdn3Wb0kXlx3h9oZ5DL6QivwdxWZx XOcOOeQ9KCtGw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1555F180050 for ; Mon, 1 Dec 2025 23:13:00 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (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 ; Mon, 1 Dec 2025 23:12:59 +0000 (UTC) Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-5942b58ac81so2529064e87.2 for ; Mon, 01 Dec 2025 15:12:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764630773; x=1765235573; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=1a2t622uOHmxmEwHWgiI6pmAG2SkUt49zSw4tm8cVjg=; b=kRDrceDvt43KDaFdPuyVJ12iwOV0sOmXbmv9j6bVE2x8hC9QuBQoq7lbQ4SEOO65Fv bYaOjMlCq40RkAeS6AXLwMAYttf1ctZGEfS3lXHAtRgOtZJw/d6IteSj+FPK/9ydaxnB R32KXhK8leIqs5FyGqPE0RZALiP8vSvNGXYIXVvFqBuJ7l9nV16q0YMYo/1KdS6EgBFc WIMRxbvtkKMgFT3xl1W24Dm1ba/1LDf6KKzTfJFS2L87IEEBENJy91n8QgOrih1+El2u X+Y2jI06rLHoMMetm4z7C7NYa1koUGdif4r3Ck8ByzvgdbKbo4l8Mp8+yM/Hdgd48LeI Oa5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764630773; x=1765235573; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=1a2t622uOHmxmEwHWgiI6pmAG2SkUt49zSw4tm8cVjg=; b=fS3Hf3DoI1UGxoJMtfUq3MOJ+V1UwrqdZdRuoWdUFpv5GmIC6CgX74Q73sQpji9EuY YXhZA2XK5XaCsaxbaytDZb3kfGh6OyiSId0MJv39TPXQRPJFQK8xTmIrfyw5G3W9z53W +6dlNk1hkdX85S1FXrMBtfCBcBFwj4HPisC3g8FvGDAWlAyE5csyppQx4rc/Z301Tf7a zP9A3z9W8nQzoV4liqGd75X/v/LXBQlNvoYyOHYGNjYCBd40JZRsDqSodt9XXYnL36X3 YuE16tCOeTjOkGDuI9NWn3lSht3z2jpfQBvMWxbwu4VwhuB0GkiJnB8hVfHRfwiTWj/v tnmA== X-Gm-Message-State: AOJu0YzqF0W+AUfQsnvnGGmn6ZBtgLP1Q1z0VyTP0Jr+xBeutv7liUz2 UfMKMxULI7Q0yF4Qk4KLL/IPmy9TiTj/u21uq/ACFx9aMUolCNt4ODUdJpifIy9tBuBG90p4qXy BlXR3jJvG56Cfs0oIIcRULuQbBHwvri8vAQ== X-Gm-Gg: ASbGncvpBUjxvdJx1YsNW35Ko1dw3NTnJ/WfUImFSelCtUVdCRo5FxpfPTAuzTNB+R1 U130iNEwzeXz/6f4OfyhNtlgreP0bJ5mavpkt4xGVsmdbFzVLuk/IFLHORTce3LgALu+KJvbkGE c22vCe2pwL7w1hTo+Uhfg+RtH8UGAgjPJ1sYIu1E/HLgLij6kTvSbXvRgFdWTrdLkFURE4Wo2bg usQZRQ44Ih2EJJlfwzwb1FPrYkCNIFmPpJRhB3TiqdFsHfRQ4HW21+YlBhD1J5SYgplcqsPlIHR pwj0O0mmNfcPQ2FKIw== X-Google-Smtp-Source: AGHT+IFyi8ZVbOD7zofyPirnzvRnkPaRTxfGO0xWBW625S47UE45ijn4OO5e8ddAwvRU0yy5gv6yyiN1N94x7EYUovA= X-Received: by 2002:a05:6512:3f1e:b0:594:55ab:57ff with SMTP id 2adb3069b0e04-596a3ecfc73mr11595545e87.33.1764630773071; Mon, 01 Dec 2025 15:12:53 -0800 (PST) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: <88368059-de1b-4598-8680-7611eab043cd@app.fastmail.com> In-Reply-To: <88368059-de1b-4598-8680-7611eab043cd@app.fastmail.com> Date: Mon, 1 Dec 2025 23:12:41 +0000 X-Gm-Features: AWmQ_bmTEahESeJNifTQEwjm_oKB6JgNE4aoUbtOMHU2nX7x2FVQ6XZRRMumZRs Message-ID: Subject: Re: [PHP-DEV] [RFC] Pattern Matching To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="0000000000006381be0644ec1e0b" From: dragoonis@gmail.com (Paul Dragoonis) --0000000000006381be0644ec1e0b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Dec 1, 2025, 10:26=E2=80=AFPM Larry Garfield wrote: > 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: > >> > >> https://wiki.php.net/rfc/pattern-matching > >> > >> You may note the date on the RFC is from 2020. Yes, we really have ha= d > this one in-progress for 5 years. :-) (Though it was inactive for many o= f > those years, in fairness.) Pattern matching was intended as the next > 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 simplifying > complex comparisons. > >> > >> This RFC has been through numerous iterations, including a full > implementation rewrite just recently that made a number of features much > easier. We have therefore included two patterns that were previously > slated for later inclusion but turned out to be trivially easy in the new > approach. (Variable pinning and numeric comparison.) > >> > >> Nonetheless, there are two outstanding questions on which we are > looking for feedback. > >> > >> Naturally given the timing, we will not be calling a vote until at > least late January, regardless of how the discussion goes. So, plenty of > time to express your support. :-) > > > > Hi Larry, > > > > Looking decent so far. > > > > match() seems a bit clunky in current state. Is it just your code > > example, and you could come with another one? > > > > The match(true) and repeating of $somevar over and over is the clunky > part. > > > > Normal match($somevar) .. this is clean and works like switch() so > > people are happy adopting it .. whereas match() and match() is, look > > 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 > what it means. While you could write the second block, you really > shouldn't when the first block is available and better. > Hi Larry, You are correct. Ignore my comment I thought it was showing the opposite. match() looks good =F0=9F=91=8D Many thanks, Paul > --Larry Garfield > --0000000000006381be0644ec1e0b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Mon, Dec 1, 2025, 10:26=E2=80= =AFPM Larry Garfield <larry@ga= rfieldtech.com> wrote:
On Mo= n, Dec 1, 2025, at 3:57 PM, Paul Dragoonis wrote:
> On Mon, Dec 1, 2025, 9:39=E2=80=AFPM Larry Garfield <larry@garf= ieldtech.com> wrote:
>> Hi folks.=C2=A0 Ilija and I would like to present our latest RFC e= ndeavor, pattern matching:
>>
>> https://wiki.php.net/rfc/pattern-matchi= ng
>>
>> You may note the date on the RFC is from 2020.=C2=A0 Yes, we reall= y have had this one in-progress for 5 years. :-)=C2=A0 (Though it was inact= ive for many of those years, in fairness.)=C2=A0 Pattern matching was inten= ded as the next follow up to Enums, as it's a stepping stone toward ful= l ADT support.=C2=A0 However, we also feel it has enormous benefit on its o= wn for simplifying complex comparisons.
>>
>> This RFC has been through numerous iterations, including a full im= plementation rewrite just recently that made a number of features much easi= er.=C2=A0 We have therefore included two patterns that were previously slat= ed for later inclusion but turned out to be trivially easy in the new appro= ach.=C2=A0 (Variable pinning and numeric comparison.)
>>
>> Nonetheless, there are two outstanding questions on which we are l= ooking for feedback.
>>
>> Naturally given the timing, we will not be calling a vote until at= least late January, regardless of how the discussion goes.=C2=A0 So, plent= y of time to express your support. :-)
>
> Hi Larry,
>
> Looking decent so far.
>
> match() seems a bit clunky in current state. Is it just your code
> example, and you could come with another one?
>
> The match(true) and repeating of $somevar over and over is the clunky = part.
>
> Normal match($somevar) .. this is clean and works like switch() so > people are happy adopting it .. whereas match() and match() is, look <= br> > 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 prop= ose to have.

The second block is what it would decompose to, aka, an explanation of what= it means.=C2=A0 While you could write the second block, you really shouldn= 't when the first block is available and better.
=


Hi Larry,

You are c= orrect. Ignore my comment I thought it was showing the opposite.=C2=A0

match() looks good =F0=9F=91= =8D=C2=A0

Many thanks,
Paul


--Larry Garfield
--0000000000006381be0644ec1e0b--