2018-06-15 11:44 GMT+02:00 Christoph M. Becker <cmbecke...@gmx.de>:

> 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
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
It's just a thought but maybe providing a new declare directive
like `declare(strict_comparison=1);` be easier for those who prefer strict
everywhere?
We have `declare(strict_types=1);` so we may have stricter declares also.
Maybe someday it turns into a standard way of working with PHP and can get
rid of declares without any code changes.
This may result in all comparisons strict without type juggling and won't
need any syntax changes at all.
And it'll apply for switch,if,else,ifselse,for,while etc. in all
comparisons.

Or maybe `declare(no_type_juggling=1)` or smth like that.

-- 
regards / pozdrawiam,
--
Michał Brzuchalski
about.me/brzuchal
brzuchalski.com

Reply via email to