LLVM talks 1: Clang for Chromium

bearophile bearophileHUGS at lycos.com
Fri Dec 16 07:46:53 PST 2011


Adam D. Ruppe:

> But I've never myself, nor seen anybody else, actually
> write += or |= when they meant == or !=. The keys aren't
> even close (on en-US anyway) so it's not a likely typo, and
> the concepts are nothing alike so a brain or language mixup
> isn't likely to cause it.
> 
> If you write "if(a += 10)", you almost certainly meant to say
> "if(a += 10)".
> 
> That's not the case with (a = 10) vs (a == 10).

OK.


> In the case of the ternary, sometimes the precidence
> is easy to forget, so I put a lot of parenthesis around
> it.
> 
> 
> return ((a) ?
>            (b) :
>            (c));
> 
> 
> Just because then each piece is obviously grouped in a certain
> way.
> 
> 
> That's just a personal style though. I don't think the language
> should enforce it since sometimes those parenthesis make it
> worse, not better, to read.

I see. But unlike the if(a|=x) case, I have seen many cases where expressions like x+b?y:0 have caused troubles (I am able to show you some examples). So I will think about this some more.


> I believe the order of evaulation is defined in D.

I don't know.

Thank you for your answer,
bearophile


More information about the Digitalmars-d mailing list