Hi Larry

> Not everything has to be a statement.

This is not what I meant. What I meant is that it should be usable in
a statement context. Since you mentioned Rust, match is always an
expression. But you can use it without making use of the return value.
This is what I'm suggesting. In PHP this is already for any expression
as well. The only difference is that we require a semicolon.

https://doc.rust-lang.org/reference/expressions/match-expr.html
https://doc.rust-lang.org/reference/statements.html

> sticking statements inside an expression is just kinda weird

This is precisely what Rust does.

https://doc.rust-lang.org/reference/expressions/block-expr.html

> If you want side effects... you already have switch.

Yes plus all the negatives mentioned in the RFC. It would be
incredibly unfortunate if we created a new construct that fixes all
those problems just to be usable only half the time.

> The point of an expression is to be evaluated into another, simpler value.

This is certainly an oversimplification. Function calls are
expressions and still have side effects a lot of the time.

> Isn't this "close enough" to pattern matching that it coves all reasonable 
> use cases

I agree. I don't think there's a convincing reason for pattern
matching in PHP right now. Nonetheless, this is not pattern matching
and we shouldn't call it that.

Regards,
Ilija

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

Reply via email to