Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129491 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 841541A00BC for ; Mon, 1 Dec 2025 21:57:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1764626267; bh=/vOV4uiXl1RCoEv65XpjmmXxjunvkzuvBXPygq8sgCo=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=P7LfXQmmzBpRvY6/GMHGhXoo0emokl32mCX3xzKIeFr6vzVLQCwpZI7QSt3LIK2zo YdJeW9PSdYQ1cdlgSQnwWQunTQHh/9QXt0kU5TldeqEjyQKgxMjJUCbJwuAJUOThc/ sOM98n7IXSsHnjwuK8OhcVs9VLAW0SIzabIa4jxMZ2eakJ++hfYB1Zfvr3GryHAme1 P+IOfgEIGDnZUkTmtECoOT9dCu6NQXUMZWmsAnIpjhqQQvurqwzJsucqc+wnegpPuO n3XwBmIlQLbcMBD11GttVj4ErEmjqopn61nNlpn33fEo6eey2kfea9jQrDYCC2QFjg 2i+MxRDVZpQ4w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 28AB7180086 for ; Mon, 1 Dec 2025 21:57:46 +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_DNSWL_NONE,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-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (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 21:57:45 +0000 (UTC) Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-37a5bc6b491so40610691fa.0 for ; Mon, 01 Dec 2025 13:57:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764626259; x=1765231059; 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=XAOizCgrEUAB4nzZkmAEi+saF40VKjbc5qGMSijyykQ=; b=R3Y3yDGqZzRrwNyr+UYsyU//O+dqjupthPsonl8QYGpD4qPwdOEYfDdbcIFAEA9zyO UAG1knog3+lvtxkeH+uH/TKATReDUO73ZRf3Vy27H5X39c7oCXmWufEwFItaZ47D/7b9 xry0DYdaEFuvHTSfeMJyVcau9WIa4aYfbjLuPBgi4yyBu4k9M05znuj88wyUM9/FRgCn 2dcRfOXTgpXlroBxKJkrxX27iR1HIxW/bCFE3Sz7DvIXA/fnHBYueGqEuJ2P2Y4hAZyH rx23kkPA5UoDYxZb/FsOyKa32xzd/9O0/4T6MOlD3246PqtfBXcySAxVhFAUKIpYmaEN CPoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764626259; x=1765231059; 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=XAOizCgrEUAB4nzZkmAEi+saF40VKjbc5qGMSijyykQ=; b=tmKFeK/MeF7BcD0AIzZD9/Rj3F2rfJ0AKnXOVcCcDVc0OqaIVwBXcoC+UPFS4vKFOn RxJ11sy9wIPMh0kW3QLm7FABFLUMB/CvCiQ0Jon2aHqfQVjY5YCuGFW009oLh1gLg5m7 bqJJtcgpeUHtFZmsS/PjsiU6BJjo/H9fllLMEy2JnNiijY0tfTMFfnfp6geT1skAbVQk HTmg83GMIeuvQz2VrxafECVHcWnNEXGLunAbV+4rnFgwffs36qnZOP0qtnqZJtS9bwSD e8TjYFdwgPaNEm5j+iSC+Wsqg1fnQVONa40aXYY+rZVZBZ1byE6d4Wc8PAw/eh1TOspa 7qRw== X-Gm-Message-State: AOJu0YxYcFNlQh0HO9bbcs3BiqsOEwQm8EGMUe3xrQnMvdV5LNVvAvvD NdJbcgnz7KTGvL6BhAWLixaNIfvqLQW4+eU2IpIfrO8ZPG5gaGQWyE0lPxqBdP9aagy055xM2vd 2Zt6ytJda74t4LzRVEZNNabfBhD/zpK5+Ow== X-Gm-Gg: ASbGncsQNwsGzy/bTRMmhe2P9KlniOzNCEV6RUBdCBj60WxlCJVKWVeq3loU22+636r 06WlyfA2YbUE1wqvKVki7EGLgetV1M+ac4zHtsf2nGtMZhLSYTGUuTPiokMBgL8pVnXCBQ25GVs EgMxGvQd9RVSIZafJUhSu89I0EiWlMxNT6uGbbSdPayviCzny7aMI5AYACVYA8+bDhV/+Y8yRrI Q+Zl4yymTsUAIe1Js73sY1xQU3rFlI9MB9j2630Q+EKsAIJAxT7YFDG0ONn2VFmSZPwXwXpNd3P pO7z+Q== X-Google-Smtp-Source: AGHT+IERfu7ntlCA+0z9JQ2Ti2o+ff7wK0M/7x+2q6WZSQmB5UKpDH9GiC9qRRIiStY30cPHnG+0WeEJaVHz5D9+3ds= X-Received: by 2002:a05:651c:4207:b0:37a:846c:3484 with SMTP id 38308e7fff4ca-37cd9164042mr97099441fa.4.1764626258847; Mon, 01 Dec 2025 13:57:38 -0800 (PST) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 1 Dec 2025 21:57:25 +0000 X-Gm-Features: AWmQ_bn0LV8CBt_-_IkgfnM07DG1DdTvaWQ9RWqLI052VvtmINnaHzCUOMxvarU Message-ID: Subject: Re: [PHP-DEV] [RFC] Pattern Matching To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="00000000000051fb9c0644eb1190" From: dragoonis@gmail.com (Paul Dragoonis) --00000000000051fb9c0644eb1190 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 had > 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? Many thanks, Paul > -- > Larry Garfield > larry@garfieldtech.com > --00000000000051fb9c0644eb1190 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Mon, Dec 1, 2025, 9:39=E2=80= =AFPM Larry Garfield <larry@ga= rfieldtech.com> wrote:
Hi fo= lks.=C2=A0 Ilija and I would like to present our latest RFC endeavor, patte= rn matching:

https://wiki.php.net/rfc/pattern-matching
You may note the date on the RFC is from 2020.=C2=A0 Yes, we really have ha= d this one in-progress for 5 years. :-)=C2=A0 (Though it was inactive for m= any of those years, in fairness.)=C2=A0 Pattern matching was intended as th= e next follow up to Enums, as it's a stepping stone toward full ADT sup= port.=C2=A0 However, we also feel it has enormous benefit on its own for si= mplifying complex comparisons.

This RFC has been through numerous iterations, including a full implementat= ion rewrite just recently that made a number of features much easier.=C2=A0= We have therefore included two patterns that were previously slated for la= ter inclusion but turned out to be trivially easy in the new approach.=C2= =A0 (Variable pinning and numeric comparison.)

Nonetheless, there are two outstanding questions on which we are looking fo= r feedback.

Naturally given the timing, we will not be calling a vote until at least la= te January, regardless of how the discussion goes.=C2=A0 So, plenty of time= to express your support. :-)

Hi Larry,

Looking decent so far.=C2=A0

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.=C2=A0

Normal match($somevar) .. this is clean and works like swit= ch() so people are happy adopting it .. whereas match() and match() is, loo= k similar but you have to use them differently ?
Can you clarify?

=
Many thanks,
Paul





--
=C2=A0 Larry Garfield
=C2=A0 larry@garfieldtech.com
--00000000000051fb9c0644eb1190--