On 2026-01-26 07:44, Larry Garfield wrote:

With per-arm, you can opt-in to pattern matching individually, at the cost of 
having to remember to repeat the keyword on every line.  With per-block, you 
only have to add the keyword once at the cost of not being able to selectively 
use patterns or identity matching.

Which tradeoff is better is the option question.  (Ilija and I disagree on 
which to go with.)  Or, if someone can suggest a way to allow automatic 
detection reliably, that would also be most welcome. :-)


If it had to be one or the other, then arms-only would be my choice as the more flexible of the two - and it's the one we have now, so the real question is if "match($foo) is {..." should be added as a shorthand for when all matching is on patterns.

I'm leaning toward "yes", especially as scalar literals would pattern match by value identity anyway. Falling back on per-arm "is" would only be necessary to address those class/constant confusions if and when they arise - but when they do you'll want it to be possible to address them.

But if "is" were required on every pattern match, that's a lot of "is"ing. People would get into the habit of using it like "case" in a switch statement (or putting backticks around every single identifier in a MySQL query), using it even when a value match is sufficient. And then having it bite them precisely in those cases when there is something like a class/constant confusion.

Reply via email to