switch case for constants-only?

grauzone none at example.net
Sat Dec 5 16:34:32 PST 2009


Nick Sabalausky wrote:
> "Ellery Newcomer" <ellery-newcomer at utulsa.edu> wrote in message 
>> It's a useful divergence. It's a feature that should exist. But I contend 
>> it makes more sense to make a new construct which *is* equivalent to a 
>> certain pattern of nested ifs (switch isn't) and incorporate your feature 
>> into that than to shoehorn it into switch.
> 
> I definitely agree we need a new switch that isn't so stuck in C-land. And 
> if we got it, I'd be perfectly happy to restrict all the new stuff to the 
> newer switch and just let C-style switch atrophy into oblivion. But a new 
> switch just doesn't seem to be happening :(.

You'd still need to keep around the old switch for stuff like Duff's 
Device. But I agree that it'd be nice to have a new switch for the 
following reasons: could use pattern matching instead of just a list of 
values, no redundant "case", no fallthrough by default, allow a more 
functional programming style.



More information about the Digitalmars-d mailing list