Re: Strict switch statements

From: Date: Fri, 15 Jun 2018 09:44:07 +0000
Subject: Re: Strict switch statements
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-102273@lists.php.net to get a copy of this message
On 15.06.2018 at 08:36, Sebastian Bergmann wrote: > Am 14.06.2018 um 10:35 schrieb Nikita Popov: > >> It might make sense to introduce an entirely new "match" statement >> that conforms a bit more with how switch-like strictures are >> implemented nowadays. That is, something like >> >> match ($expr) { >> "foo" => {...}, >> "bar" | "baz" => {...}, >> } >> >> or similar. > > Interesting. Can you provide a pointer to a language that has a match > statement like that? This match statement (or would it be an expression?) could be regarded as an extremly simplified syntactic variant of the case-of expression of Standard ML[1]. Instead of the pipe operator we could use a comma to separate multiple “patterns”. Using “case” instead of “match” appears to be something to consider as well. [1] <https://www.cs.cornell.edu/courses/cs312/2004fa/lectures/lecture3.htm>, section “Pattern Matching” -- Christoph M. Becker

« previous php.internals (#102273) next »