switch case for constants-only?

Nick Sabalausky a at a.a
Sat Dec 5 16:25:38 PST 2009


"Ellery Newcomer" <ellery-newcomer at utulsa.edu> wrote in message 
news:hfer6b$15d1$1 at digitalmars.com...
> On 12/05/2009 04:19 PM, Nick Sabalausky wrote:
>> "Ellery Newcomer"<ellery-newcomer at utulsa.edu>  wrote in message
>>>
>>> More so than remembering to type break after each case block?
>>
>> Good point, but that's really a separate issue.
>>
>>
>
> I don't know about that. The issue seems to be you want switch to behave 
> in a manner unlike that of any other language that I know of.
> It's different. It breaks convention.
>
> 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 :(.

Also, I still don't see how there's any semantic difference between the 
current switch and the switch-like if-else chain other than just the fact 
that switch currently carries the restriction that the values being checked 
against must be unique and known at compile time. 





More information about the Digitalmars-d mailing list