No more fall through in case statement?

Jason House jason.james.house at gmail.com
Sun Jan 13 19:53:09 PST 2008


Robert DaSilva wrote:

> Michel Fortin wrote:
>> On 2008-01-07 20:48:54 -0500, bearophile <bearophileHUGS at lycos.com> said:
>> 
>>> In the Python community people collect use cases, do a simple
>>> frequency count of them, and then usually look for a simple solution
>>> able to cover most of them. So we can collect some use cases of the
>>> switch. I presume most use cases are covered by a Pascal-like syntax.
>>> The other situations are probably covered by putting commas between
>>> alternative cases. What other use cases do you people have?
>> 
>> A use case?
>> 
>> I quite fancy GCC's extension which allows you to put ranges in case
>> statements, for instance:
>> 
>>     switch (myChar) {
>>         case 'a'...'z':
>>         case 'A'...'Z':
>>         case '0'...'9':
>>             // do something.
>>     }
>> 
>> I think D should have it too. (Also, since we're at it, it's covered by
>> Pascal.)
>> 
> 
> Yes, but it would be 'A' .. 'Z' not 'A' ... 'Z'.

That's always bugged me.  Seems too easy for coding errors.



More information about the Digitalmars-d mailing list