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

Don nospam at nospam.com
Mon Jun 21 21:11:36 PDT 2010


Adam Ruppe wrote:
> On 6/21/10, Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org> wrote:
>> Then why are people using switch and next to nobody uses fall through
>> (provably including Walter, who thinks is using fall through "all the
>> time")?
> 
> Do you have some stats from the phobos and dmd source? I ran a crude
> text pattern program, and it said about 10% of cases fall through in
> them combined, but since it is so simple, it is surely inaccurate. (It
> gave 1% for druntime, and 3% for my own code, then 10% for dmd and
> phobos both. All numbers are rounded to one significant figure.
> 
> That 3% is surprising - I know I use fallthrough all the time, but
> most the cases are two cases right next to each other, one one case
> falling through to default, which my program didn't count. It only
> considered a case to fallthrough if there was at least one semicolon
> between it and the next, and it ignored "default".

Did you consider situations where the last thing before the case is 
actually a 'goto' ? Walter does that a lot.

> 
> If it included "case '(': case ')':", like in std.regex, it would be
> much higher, but if the patch disallows that, they'll be riots in the
> streets, so it isn't going to happen.)
> 
> Anywho, if my program is even in the right ballpark, I wouldn't call
> that "next to nobody". 10% is a pretty big amount.
> 
> 
> 
> 
> On 6/21/10, Leandro Lucarella <luca at llucax.com.ar> wrote:
>> Well, while, do..while are also redundant, you can do it with for. And
>> you can do for with goto!
> 
> Indeed. goto is a kind of comfort construct to me. Even if I never use
> it, it is reassuring to know it is there if I need it. Anything can be
> built out of goto!
> 
>> And you can still use fall-through with the proposed semantics of
>> switch, it's just making it explicit instead of implicit.
> 
> I tend to write
> // fallthrough
> right now anyway to silence [s]the incompetent dweebs[/s] my valued
> colleagues who complain about fallthrough being there, so assuming the
> patch doesn't make me riot in the streets, I know it isn't really that
> big of a change. But still, I resist all change on principle anyway :)


More information about the Digitalmars-d mailing list