What the hell is wrong with D?
Eugene Wissner
belka at caraus.de
Tue Sep 19 17:53:31 UTC 2017
On Tuesday, 19 September 2017 at 17:40:20 UTC, EntangledQuanta
wrote:
>
> writeln(x + ((_win[0] == '@') ? w/2 : 0));
> writeln(x + (_win[0] == '@') ? w/2 : 0);
>
> The first returns x + w/2 and the second returns w/2!
>
> WTF!!! This stupid bug has caused me considerable waste of
> time. Thanks Walter! I know you care so much about my time!
>
> I assume someone is going to tell me that the compiler treats
> it as
>
> writeln((x + (_win[0] == '@')) ? w/2 : 0);
>
> Yeah, that is really logical! No wonder D sucks and has so many
> bugs! Always wants me to be explicit about the stuff it won't
> figure out but it implicitly does stuff that makes no sense.
> The whole point of the parenthesis is to inform the compiler
> about the expression to use. Not use everything to the left of
> ?.
>
> Thanks for wasting some of my life... Just curious about who
> will justify the behavior and what excuses they will give.
Why do you claim that a bug in your code is a compiler bug? Check
"Operator precedence" [1]. There is really no reason why the
current precedence is less "logical" than what you're awaiting.
And try to think about things you're writing, nobody forces you
to use D.
[1] https://wiki.dlang.org/Operator_precedence
More information about the Digitalmars-d-learn
mailing list