What the hell is wrong with D?

EntangledQuanta EQ at universe.com
Tue Sep 19 19:16:05 UTC 2017


On Tuesday, 19 September 2017 at 18:51:51 UTC, Jesse Phillips 
wrote:
> On Tuesday, 19 September 2017 at 17:40:20 UTC, EntangledQuanta 
> wrote:
>> 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!
>
> Yeah, I've been bitten by that in languages like C#. I wish D 
> didn't follow in C#'s footsteps and chosen a different syntax: 
> `()? :`
>
> That way if there aren't any parentheses the compiler could 
> throw out an error until you specify what the operating is 
> working with. It would make for a little overhead but these 
> complex ternary expressions can be confusing.

Yes, it's not that they are confusing but illogical.

a + b ? c : d

in a complex expression can be hard to interpret if a and b are 
complex. The whole point of parenthesis is to disambiguate and 
group things. To not use them is pretty ignorant.

1 + 2 ? 3 : 4

That is ambiguous. is it (1 + 2) ? 3 : 4 or 1 + (2 ? 3 : 4)?

Well,

()?: is not ambiguous!

The D community preaches all this safety shit but when it comes 
down to it they don't seem to really care(look at the other 
responses like like "Hey, C does it" or "Hey, look up the 
operator precedence"... as if those responses are meaningful).

I'm just glad there is at least one sane person that decided to 
chime in... was quite surprised actually. I find it quite 
pathetic when someone tries to justify a wrong by pointing to 
other wrongs. It takes away all credibility that they have.











More information about the Digitalmars-d-learn mailing list