Extend D's switch statement?

Vlad Levenfeld via Digitalmars-d digitalmars-d at puremagic.com
Wed Jul 8 09:00:43 PDT 2015


On Wednesday, 8 July 2015 at 08:31:42 UTC, Martin Nowak wrote:
> On Wednesday, 8 July 2015 at 07:15:27 UTC, Yuxuan Shui wrote:
>> I think it will be useful to extent switch statement to 
>> support any type that implements opEquals and opHash.
>>
>> Is there any technical difficulties to implement this?
>
> Hardly anyone wants switch to be a better if-else ladder.
> https://issues.dlang.org/show_bug.cgi?id=5862
> Many would like it to support pattern matching though.
> http://wiki.dlang.org/DIP32#Various_places_that_you_can_use_unpacking_and_pattern_matching

I would really like to see tuples become part of the language, 
maybe with automatic unpacking when they are passed as function 
args (if the function doesn't explicitly require a tuple in that 
position).


More information about the Digitalmars-d mailing list