June 09, 2009
Saaa wrote:
>>> What kind of fall-throughs were these?
>>>
>>> A:
>>>
>>> case value1:
>>> case value2:
>>> case valueN:
>>>     code1();
>>>     break;
>>>
>>> B:
>>>
>>> case value1:
>>>     code1();
>>> case value2:
>>>     code2();
>>>     break;
>> The solution is to forbid fallthrough, and change the switch syntax:
>>
>> switch(value) {
>>   case 1:
>>   case 2:
>> // something
>> break;
>> }
>>
>> gives: Error, missing break at the end of case1.
>>
>> But:
>>
>> switch(value) {
>>   case 1, 2:
>> // something
>> break;
>> }
>>
>> works as expected.
>>
>> What's wrong with that?
> 
> Doesn't support B :)
> 
> How about a warning instead? 

The idea is that it not supporting B is something good.

An error is ok, and if you want to translate C code then it's really easy to change the code to not give errors.
June 09, 2009
>>> What's wrong with that?
>>
>> Doesn't support B :)
>>
>> How about a warning instead?
>
> The idea is that it not supporting B is something good.
I know this is your idea, but as BCS doesn't support this idea. You should have replied to him iso grauzone.

I personally never had any problems with falling through.
The IDE  ( descent :) indents it nicely.


> An error is ok, and if you want to translate C code then it's really easy to change the code to not give errors.

I don't think you will get that, thus maybe a warning is better than nothing?


June 09, 2009
Saaa wrote:
>>>> What's wrong with that?
>>> Doesn't support B :)
>>>
>>> How about a warning instead?
>> The idea is that it not supporting B is something good.
> I know this is your idea, but as BCS doesn't support this idea.

How do you know? BCS didn't reply to my idea.

> You should have replied to him iso grauzone.
> 
> I personally never had any problems with falling through.
> The IDE  ( descent :) indents it nicely.
> 
> 
>> An error is ok, and if you want to translate C code then it's really easy to change the code to not give errors.
> 
> I don't think you will get that, thus maybe a warning is better than nothing?

A warning *is* nothing. :-P
June 09, 2009
> How do you know? BCS didn't reply to my idea.

Your idea was to give an error on the case (B) he uses. Or did I miss something?


June 09, 2009
Saaa wrote:
>> How do you know? BCS didn't reply to my idea.
> 
> Your idea was to give an error on the case (B) he uses. Or did I miss something? 

You missed the alternative syntax to get the same behaviour. But it's a very subtle difference.
June 09, 2009
> You missed the alternative syntax to get the same behaviour. But it's a very subtle difference.

Do you mean the multiple cases? http://www.digitalmars.com/d/1.0/statement.html#SwitchStatement


June 09, 2009
Saaa wrote:
>> You missed the alternative syntax to get the same behaviour. But it's a very subtle difference.
> 
> Do you mean the multiple cases?
> http://www.digitalmars.com/d/1.0/statement.html#SwitchStatement 

Yes, but make the "multiple cases" the *only* way to make case statements fallthrough. That would be the change.
June 09, 2009
> Yes, but make the "multiple cases" the *only* way to make case statements fallthrough. That would be the change.

That is the same as giving an error on case B, right?


June 09, 2009
I mean, the syntax stays the same.


June 09, 2009
Saaa wrote:
>> Yes, but make the "multiple cases" the *only* way to make case
>> statements fallthrough. That would be the change.
> 
> That is the same as giving an error on case B, right?

Well, yes, but you also have to prepare your mind for the change. This is a huge step.

(nah, just kidding, you're right, I didn't realize it :-P)