Re: [Early Feedback] Pattern matching

From: Date: Tue, 06 Aug 2024 08:17:31 +0000
Subject: Re: [Early Feedback] Pattern matching
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-124793@lists.php.net to get a copy of this message
Le jeudi 20 juin 2024, 19:38:40 UTC+2 Larry Garfield a écrit : > To that end, we're looking for *very high level* feedback on this RFC: > > https://wiki.php.net/rfc/pattern-matching Hello, Thank you for this RFC. Sorry if that’s a bit focused on syntax, but I’m really concerned by the binding syntax. I would totally expect both these codes to do the same thing: ``` if ($o is Class{prop: 3}) { ``` and: ``` $x = 3; if ($o is Class{prop: $x}) { ``` I’ve seen someone else in the discussion propose to invert the logic between binding and use a variable and I agree, it’s the binding/capture which should have the special syntax. Either another operator than ':', I’ve seen '=>' proposed. Or any other idea to differentiate it. '=>' would allow to combine match and capture like this: $o is Class{prop: int => $y} Côme

« previous php.internals (#124793) next »