switch case for constants-only?

Nick Sabalausky a at a.a
Sat Dec 5 17:03:28 PST 2009


"grauzone" <none at example.net> wrote in message 
news:hfeu6p$1apu$1 at digitalmars.com...
> 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.

I have to admit, I'm so jealous of what I've seen of Nemerle's pattern 
matching (and it's metaprogramming), that I've been tempted to to give a 
shot at switching to it for things that don't strickly need system-level 
capabilities. 





More information about the Digitalmars-d mailing list