Re: [RFC] Pattern Matching

From: Date: Wed, 10 Dec 2025 19:06:16 +0000
Subject: Re: [RFC] Pattern Matching
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-129585@lists.php.net to get a copy of this message
On Wed, Dec 10, 2025, at 12:20 PM, Tim Düsterhus wrote: > Hi > > Am 2025-12-10 14:37, schrieb Vinicius Dias: >>> This particular syntax was chosen as it is the same as in Ruby, the >>> only other language we know of that has this functionality. >> >> I don't know how helpful this info is, but I'll provide it anyway. >> Elixir and Erlang also have the functionality and its syntax is the >> same, using the ^ character. >> >> >> https://hexdocs.pm/elixir/pattern-matching.html#the-pin-operator > > AFAICT this is not quite right. It is supported in Elixir, but not in > Erlang. There is a proposal to add it to Erlang, but the corresponding > PR is still open, which indicates that it is not accepted yet: > https://www.erlang.org/eeps/eep-0055 > > It's not surprising to me that Elixir supports it, since Elixir is > heavily inspired / influenced by Ruby. > > Best regards > Tim Düsterhus Still, it's good information to have. That means two languages using the ^ character, and no one using anything else instead. We went with ^ largely because "well, that's what Ruby does, and it's easy to implement that way." So if it's more of a common standard (the way |> is the standard spelling of pipe), that's another argument to follow suit and not complicate things. Thanks, Vinicius! --Larry Tarfield

« previous php.internals (#129585) next »