Re: [RFC] Short-match
| From: | Larry Garfield | Date: | Sat, 19 Dec 2020 01:47:49 +0000 |
| Subject: | Re: [RFC] Short-match | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-112552@lists.php.net to get a copy of this message | ||
On Fri, Dec 18, 2020, at 1:40 PM, Olle Härstedt wrote:
> What about matching on a variable's type?
>
> ```
> match {
> $var: string => "is a string"
> $var: array => "something else"
> }
> ```
>
> This could be used with flow-sensitive typing, e.g. assume the type of $var
> being string in the string block. Psalm works like this for if-statements.
> Also consider the case with generics.
>
> Compare with generalised algebraic data types in FP (GADT).
>
> Olle
That would be more along the lines of the pattern matching RFC that Ilija and I have been kicking
around for post-enums: https://wiki.php.net/rfc/pattern-matching
That's still in the "it would be cool if" stage only, and is IMO off topic from the
abbreviation effort in this RFC.
--Larry Garfield