Improvements to switch

Dukc ajieskola at gmail.com
Wed Apr 24 07:55:13 UTC 2024


On Tuesday, 16 April 2024 at 10:34:21 UTC, ryuukk_ wrote:
> It is time to make them nice to use
>
> - allow them as expression
> - more concise
> - pattern match

I'm certainly open to exploring the general notion. I think 
Walter is too, at least regarding the last one, as I recall he 
has said somewhere that D will have pattern matching.

However, whether we actually want to change `switch` depends on 
the details, exactly how are we going to do it? Every new 
langauge feature has to consider added language complexity, 
corner cases and backwards compatibility questions. How hard 
those are to deal with, compared to the benefit, is the ultimate 
test of worth for the feature.

I somewhat tend to agree with Walter. `switch` works how it works 
thanks to C heritage, as a result it has a lot of backwards 
compatibility burden. Any attempt to overhaul it to support 
pattern matching as a primary use case is probably going to 
complicate the language more than just designing a new construct.

But I'm not locked to this position - if someone presents a 
clever `switch` upgrade proposal along with the details, I'd be 
happy to be proven wrong.


More information about the dip.ideas mailing list