Match statement
Many "modern" languages have match. C++: P1371R2, C++17 matchit.cpp Python: the-match-statement Rust: patterns
It would be nice to add it to C3.
I think the added complexity is not worth it. Note that there is already partial support for what match does as case supports both ranges and non-constant expressions.
Consequently both case 45 .. 60: and case foo(): works.
the added complexity is not worth it
The complexity is in implementation, but not in usage.
casesupports both ranges and non-constant expressions.
Sure, I know. Let case stays for simple types.
Complexity in implementation is complexity in learning. I have not seen sufficient usefulness of it. The actual uses of it over an extended case is as far as I can tell fairly minimal.
I've also added:
switch
{
case x == 100:
...
case x > 100:
...
}
What use cases do you want match for?
Can we close this @data-man ?
Close it if you want. And I've added Ruby's docs with many useful examples.
Probably this can be implemented by macros but single underscore isn't allowed as identifier.