Is there ANY chance we can fix the bitwise operator precedence rules?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Jun 21 14:10:17 PDT 2010


On 06/21/2010 03:46 PM, Sean Kelly wrote:
> Andrei Alexandrescu<SeeWebsiteForEmail at erdani.org>  wrote:
>> On 06/21/2010 01:27 PM, Sean Kelly wrote:
>>> Jonathan M Davis Wrote:
>>>>
>>>> In any case, that means that it could be made required to have a
>>>> control
>>>> statement at the end of a case block without having to specify a
>>>> specific
>>>> destination for fallthrough - though I'd prefer "continue switch"
>>>> over "goto
>>>> case" since it's more explicit and less error prone (since there's
>>>> no doubt
>>>> that you didn't intend to put a destination for the goto if you use
>>>> "continue switch" instead of a "goto case" without a destination).
>>>
>>> It's a small thing, but I think "continue switch" could be
>>> misleading.  Consider this:
>>>
>>> switch (getState()) {
>>> case X:
>>>       setState(Z);
>>>       continue switch;
>>> case Y:
>>>       break;
>>> case Z:
>>>       writeln( "done!" );
>>> }
>>>
>>> Having never encountered D before, what would be your interpretation
>>> of this code?
>>
>> Well looks pretty good to me to be honest.
>
> So would you say "done!" is printed or not?

I'd say "continue switch" does not reevaluate getState() because switch 
is not a looping statement. So I'd think it simply continues down, so 
writeln is not printed.

But I realize I am biased.

Andrei


More information about the Digitalmars-d mailing list