Re: [RFC] Short-match

From: Date: Sun, 20 Dec 2020 10:31:54 +0000
Subject: Re: [RFC] Short-match
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-112562@lists.php.net to get a copy of this message
On Sat, 19 Dec 2020, 02:48 Larry Garfield, <larry@garfieldtech.com> wrote:

> 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
>

Very cool. Thanks for the link. Looking forward to further implementations!

Olle

-- 
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: https://www.php.net/unsub.php
>
>


Thread (29 messages)

« previous php.internals (#112562) next »