Re: [RFC] Pattern Matching

From: Date: Sun, 14 Jun 2026 18:22:29 +0000
Subject: Re: [RFC] Pattern Matching
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-131241@lists.php.net to get a copy of this message
Greetings! Thanks for the awesome RFC, I very much like the suggestion and would highly welcome it in general. But since the proposed update is really huge, I've got some concerns about some specific use-cases of it. My main concern is about variable binding / pinning. To me personally your current suggestion looks very counter-intuitive, which means that when I see a variable inside the patter, I would strongly expect it as a reference to an existing variable as part of the pattern: $b = 5; $a = 3; if ($a is $b) {...} Which translates to if $a === $b. Of course, same relates to more complex patterns. On Sun, Jun 14, 2026 at 9:08 PM Larry Garfield <larry@garfieldtech.com> 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 of 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. :-) > > -- > Larry Garfield > larry@garfieldtech.com

« previous php.internals (#131241) next »