What the hell is wrong with D?

EntangledQuanta EQ at universe.com
Tue Sep 19 17:40:20 UTC 2017


	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.


More information about the Digitalmars-d-learn mailing list