Search
```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!

Yeah, it sucks to have bugs like this crop up. I have enough trouble remembering operator precedence, so I end up using parentheses everywhere and pretending the ternary operator doesn't exist. I also tend to break up complex expressions a lot. It's just safer, and usually clearer.
```
```On Tuesday, 19 September 2017 at 20:00:40 UTC, Brad Anderson wrote:
>
> If you want to help, I suggest trying to come up with a DIP that addresses it while being conscious of how to avoid breaking an enormous amount of code. I suspect it's a hard and maybe impossible problem but if you are up for the challenge I'm sure your efforts would be welcome.

Changing the operator precedence would certainly lead to enormous breakage.

Most use of the ternary operator is something like
result = a > b ? x : y;
and what he wants is to be forced to say
result = (a + b) ? x : y;
result = a + b ? x : y;

The problem is that addition/multiplication is above logical operators in the operator precedence. So if you were to do something like move conditional ternary above addition/multiplication, then you also move it above logical operators and you'd have to use
result = (a > b) ? x : y;
result = a > b ? x : y;
which kind of defeats the purpose.
```
```On Tuesday, 19 September 2017 at 17:40:20 UTC, EntangledQuanta wrote:
> 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 ?.

There are two issues there; operator precedence and booleans (_win[0] == '@') being a valid operands to +.
If someone is too stupid to learn how precedence works, they should consider a different career instead of blaming others.
OTOH, booleans converting to numbers is a very questionable feature. I certainly have never seen any good use for it. This is just an unfortunate legacy of C, which didn't even have booleans for a long time.

```
```On Tuesday, 19 September 2017 at 19:16:05 UTC, EntangledQuanta wrote:
> 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).

jmh530 points out why you're met with such non-agreement of the issue. You're not open do discussion of why it is implemented in the fashion it is. Instead it is an attack on the community and Walter as though there is no logical reason it is implemented in the way that it is.

Sure you can express that it is illogical to have made that choice, but that requires first know what used to make that decision.

For example one of the original principles for D was:
If it looks like C it should have the same semantics or be a compiler error (note this was not completely achieved)

Now if we look at other languages we see, they implement it the same as C or they don't implement it at all. Just based on this it would make sense to choose to implement it like C if it is desired to have.

The suggestion I made fulfills this, but it also slightly defeats one purpose of the operator, being terse.

We also now need to keep backwards compatibility, this fails.
```
```On 19/09/2017 9:22 PM, Neia Neutuladh wrote:
> 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!
>
> Yeah, it sucks to have bugs like this crop up. I have enough trouble remembering operator precedence, so I end up using parentheses everywhere and pretending the ternary operator doesn't exist. I also tend to break up complex expressions a lot. It's just safer, and usually clearer.

Agreed, no surprises is the best surprise!

```
```On Tuesday, 19 September 2017 at 21:17:53 UTC, nkm1 wrote:
> On Tuesday, 19 September 2017 at 17:40:20 UTC, EntangledQuanta wrote:
>> 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 ?.
>
> There are two issues there; operator precedence and booleans (_win[0] == '@') being a valid operands to +.
> If someone is too stupid to learn how precedence works, they should consider a different career instead of blaming others.
> OTOH, booleans converting to numbers is a very questionable feature. I certainly have never seen any good use for it. This is just an unfortunate legacy of C, which didn't even have booleans for a long time.

Your an idiot, I know about how operator precedence works far more than you do. Wanna bet? how much? Your house? your wife? Your life? It's about doing things correctly, you seem to fail to understand, not your fault, can't expect a turd to understand logic.
```
```On Tuesday, 19 September 2017 at 22:11:44 UTC, Jesse Phillips wrote:
> On Tuesday, 19 September 2017 at 19:16:05 UTC, EntangledQuanta wrote:
>> 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).
>
>
> jmh530 points out why you're met with such non-agreement of the issue. You're not open do discussion of why it is implemented in the fashion it is. Instead it is an attack on the community and Walter as though there is no logical reason it is implemented in the way that it is.
>
I'm not open to discussion because it is not a discussion. There is no point. What could would it do to explain the short commings? You see the responses, the mentality. People think doing something wrong is valid because it was done. Two wrongs don't make a right no matter how you justify it. When someone takes on the task of doing a job and pretends the results to a community then refuse to accept responsibility for the failure to do the job properly and perpetuate ignorance(invalid logic that creates confusing, wastes peoples times, etc) then they deserve to be criticized, it's a two way street. When they then make up excuses to try to justify the wrong and turn it in to a right, they deserved to be attacked. It not just a harmless mistake. Peoples lives could be a jeopardy, but do they care? Do they REALLY care? Of course not. They don't see it as a significant issue. Simply learn how D works exactly and you'll be fine! Of course, for someone that programs in about 20 different languages regularly, having logical consistency is important.

It's one thing to say "Well, I made a mistake, lets try to remedy it the best we can" than to say "Well, too bad, we can't break backwards compatibility!". People want to perpetuate insanity(which is what being illogical is).

> Sure you can express that it is illogical to have made that choice, but that requires first know what used to make that decision.

No, it doesn't logic is not based on circumstances, it's based on something that is completely independent of us... which is why it is called logic... because it is something we can all agree on regardless of our circumstances or environment... it is what math and hence all science is based on and is the only real thing that has made steady progress in the world. Illogic is what all the insanity is based on... what wars are from, and just about everything else, when you actually spend the time to think about it, which most people don't.

> For example one of the original principles for D was:
> If it looks like C it should have the same semantics or be a compiler error (note this was not completely achieved)
>
> Now if we look at other languages we see, they implement it the same as C or they don't implement it at all. Just based on this it would make sense to choose to implement it like C if it is desired to have.
>
> The suggestion I made fulfills this, but it also slightly defeats one purpose of the operator, being terse.
>
> We also now need to keep backwards compatibility, this fails.

Again, two wrongs don't make a right. What is the point of reimplementing C exactly as C is done? There is already a C, why have two? Was the whole point of D not to improve upon C? Doesn't D claim to be a "better C"? So, if you are claiming that the choice for the ternary operator's issue of ambiguity was to be consistent with C then that directly contradicts the statements that D is suppose to be safer and better. I'm fine with this AS long as it is clearly stated as such and people don't try to justify or pretend that it is a good thing, which is exactly the opposite of what they. Most are followers of the cult and cannot make any rational decision on their own but simply parrot the elders. So, when they do that, I have no desire or reason to be logical with them(again, it takes two to tango).

For example, you have been rational, so I will be rational with you. To be rational, you must argue logically which you have done. Even though you haven't really argued the issue(of course, I didn't state it clear on purpose because this isn't really a discussion thread... I knew that the trolls/cult members would spew there stupid shit so I was just trolling them. Of course, I always hope that there would be some light in the tunnel, which you provided a glimmer... still all meaningless, nothing will change, at least not with the cult members, but someone that is not so brainwashed might be semi-enlightened if they implement their own language and not make the same mistakes).

e.g., my attack is on the claims that D attempts to be *safe* and a *better C* and yet this(the ternary if) is just another instance of them contradicting themselves. Presenting something as safer when it is not gives the perception of safety and can actually be more dangerous than the original.
```
```On Wednesday, September 20, 2017 02:16:16 EntangledQuanta via Digitalmars-d- learn wrote:
> On Tuesday, 19 September 2017 at 21:17:53 UTC, nkm1 wrote:
> > On Tuesday, 19 September 2017 at 17:40:20 UTC, EntangledQuanta
> >
> > wrote:
> >> 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 ?.
> >
> > There are two issues there; operator precedence and booleans
> > (_win[0] == '@') being a valid operands to +.
> > If someone is too stupid to learn how precedence works, they
> > should consider a different career instead of blaming others.
> > OTOH, booleans converting to numbers is a very questionable
> > feature. I certainly have never seen any good use for it. This
> > is just an unfortunate legacy of C, which didn't even have
> > booleans for a long time.
>
> Your an idiot, I know about how operator precedence works far more than you do. Wanna bet? how much? Your house? your wife? Your life? It's about doing things correctly, you seem to fail to understand, not your fault, can't expect a turd to understand logic.

Please try to be civil. It's fine if you're unhappy about some aspect of how D works and want to discuss it, but we do not condone personal attacks here.

- Jonathan M Davis

```
```On Wednesday, 20 September 2017 at 02:16:16 UTC, EntangledQuanta wrote:
> Your an idiot, I know about how operator precedence works far more than you do. Wanna bet? how much? Your house? your wife? Your life? It's about doing things correctly, you seem to fail to understand, not your fault, can't expect a turd to understand logic.

You should swallow your ego a bit. In first place you've made an error. Just recognize this error, it's not so serious finally. You are discrediting yourself for nothing.
```
```On Wednesday, 20 September 2017 at 02:36:50 UTC, Jonathan M Davis wrote:
>
> Please try to be civil. It's fine if you're unhappy about some aspect of how D works and want to discuss it, but we do not condone personal attacks here.
>
> - Jonathan M Davis

He seemed to be threatening the guy's life over operator precedence. Ridiculous...
```
1 2 3 4