Hi Larry

Thanks for your suggestion.

I chose to use switch instead of match for a couple of reasons:

1. It uses the same AST, code generation and opcodes as the switch, I
don't agree that it is significantly different than the switch that we
already have.
2. Adding the `match` keyword is a breaking change, not an insignificant one.
3. If we can fix the switch statement semantics in the future the two
will only differ in that one returns a value and the other one
doesn't. This is a much smaller distinction than functions/closure.
4. If we'd every want to add pattern matching, we'd still have a
keyword available to us.

> I don't believe that's the case here, however.  `switch` is a language 
> construct for a *statement*, which branches the flow of control of the 
> program.
>
> What you're proposing is a language construct for an *expression*, which 
> evaluates depending on internal logic to a different value.

Well, I encourage you to look at the implementation. You'll see that
the two are in fact very similar.

I'm not averse to using the match keyword if people are ok with the BC
change. If we do though we definitely should make it work as a
statement, allow blocks in addition to single expression and also fix
type coercion. This would make it a replacement of the switch
statement instead of an addition.

Ilija

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

Reply via email to