Re: What the hell is wrong with D?

2017-10-04 Thread Tristan B. Kildaire via Digitalmars-d-learn

On 2017/09/19 19:40, 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.
When you get too angry about the little things in life. "There are 
people dying in the world and this angers you, chill".


Re: What the hell is wrong with D?

2017-09-26 Thread Brad Anderson via Digitalmars-d-learn
On Saturday, 23 September 2017 at 20:43:36 UTC, Patrick Schluter 
wrote:
So I checked for all the languages listed: C, C#, Java, 
Javascript, C++, PHP, Perl and D. All have the same order of 
precedence except, as always the abomination of all languages: 
C++ (kill it with fire).
C++ is the only language that has the ternary operator have the 
same precedence than the assignment operators.
This means a>=5?b=100:b=200; will compile in C++ but not in all 
the other languages. That's one reason why it irritates me when 
people continuously refer to C and C++ as if it was the same 
thing (yes I mean you Walter and Andrei).
Even PHP and Perl got it right, isn't that testament of poor 
taste Bjarne?. :-)


It's not quite as big of a deal as it seems because of the RTL 
associativity for both of them but still a very weird thing at 
face value.


Re: What the hell is wrong with D?

2017-09-23 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 19 September 2017 at 18:34:13 UTC, Brad Anderson 
wrote:

On Tuesday, 19 September 2017 at 18:17:47 UTC, jmh530 wrote:
On Tuesday, 19 September 2017 at 17:40:20 UTC, EntangledQuanta 
wrote:


Thanks for wasting some of my life... Just curious about who 
will justify the behavior and what excuses they will give.


Pretty sure it would be exactly the same thing in C...


It is (and Java and C# and pretty much every other C style 
language though the nicer implicit conversion rules means it 
gets caught more easily). It is a big source of programmer 
mistakes. It comes up frequently in PVS Studio's open source 
analysis write ups.


So I checked for all the languages listed: C, C#, Java, 
Javascript, C++, PHP, Perl and D. All have the same order of 
precedence except, as always the abomination of all languages: 
C++ (kill it with fire).
C++ is the only language that has the ternary operator have the 
same precedence than the assignment operators.
This means a>=5?b=100:b=200; will compile in C++ but not in all 
the other languages. That's one reason why it irritates me when 
people continuously refer to C and C++ as if it was the same 
thing (yes I mean you Walter and Andrei).
Even PHP and Perl got it right, isn't that testament of poor 
taste Bjarne?. :-)





Re: What the hell is wrong with D?

2017-09-22 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 19 September 2017 at 18:34:13 UTC, Brad Anderson 
wrote:

On Tuesday, 19 September 2017 at 18:17:47 UTC, jmh530 wrote:
On Tuesday, 19 September 2017 at 17:40:20 UTC, EntangledQuanta 
wrote:


Thanks for wasting some of my life... Just curious about who 
will justify the behavior and what excuses they will give.


Pretty sure it would be exactly the same thing in C...


It is (and Java and C# and pretty much every other C style 
language though the nicer implicit conversion rules means it 
gets caught more easily). It is a big source of programmer 
mistakes. It comes up frequently in PVS Studio's open source 
analysis write ups.


So I checked for all the languages listed: C, C#, Java, 
Javascript, C++, PHP, Perl and D. All have the same order of 
precedence except, as always the abomination of all languages: 
C++ (kill it with fire).
C++ is the only language that has the ternary operator have the 
same precedence than the assignment operators.
This means a>=5?b=100:b=200; will compile in C++ but not in all 
the other languages. That's one reason why it irritates me when 
people continuously refer to C and C++ as if it was the same 
thing (yes I mean you Walter and Andrei).
Even PHP and Perl got it right, isn't that testament of poor 
taste Bjarne?. :-)





Re: What the hell is wrong with D?

2017-09-20 Thread Azi Hassan via Digitalmars-d-learn
A general rule of thumb when it comes to operator precedence is 
that when in doubt, add parenthesis.


On Wednesday, 20 September 2017 at 02:16:16 UTC, EntangledQuanta 
wrote:

Your an idiot,
Your


Huh.


Communication was [Re: What the hell is wrong with D?]

2017-09-20 Thread Jesse Phillips via Digitalmars-d-learn
On Wednesday, 20 September 2017 at 02:34:50 UTC, EntangledQuanta 
wrote:
When they then make up excuses to try to justify the wrong and 
turn it in to a right, they deserved to be attacked.


That isn't how it went down, you attacked then justification was 
provided.


for someone that programs in about 20 different languages 
regularly, having logical consistency is important.


Could you imagine if D didn't allow you to learn how ternary is 
implemented? when you switched to one of those 19 other languages 
you'd expect it to work like D and make that catastrophic life 
threatening mistake you speak of.


But at last D followed logical consistency across languages so 
you can make the mistake once, learn, and apply it to all the 
other environments you're using.



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.


I will claim that it is illogical to make decisions ignoring 
environment and circumstances. For example, science heavily 
leverages environment (e.g. all objects fall at the same rate; 
environment: vacuum) (e.g. matter can neither be created nor 
destroyed; environment: not within a atomic explosion) (e.g. ...; 
environment: anything not quantum mechanics) (e.g. this satellite 
will follow this trajectory; environment: forces acting upon the 
satellite)


Again, two wrongs don't make a right. What is the point of 
reimplementing C exactly as C is done?


I don't think there were any unjust or dishonest actions being 
done. Just an FYI the phrase isn't intended to be applied to all 
meanings of 'wrong'.


If you're a C(C++,C#,Java,...) programmer (environment) then when 
you are reading D code you will understanding the semantics and 
the semantics will remain the same if you copy code from your 
language into D.


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.


Safe to Walter has always been 'memory safe' but to you point of 
broader safety lets take my ()?: syntax and breaking backwards 
compatibility here is unsafe.


q > a / (3 + 4) ? 0 : q;

This compiles today, it will also compile with the new syntax; 
the semantics would be completely different. This is a 
calculation running in production for a space shuttle to Mars. 
Before the launch they upgrade the compiler and this new 
calculation causes the shuttle to land in Florida off the coast 
of Minneapolis.


Backwards compatibility is important to safety just as following 
the majority. To ignore the environment you're working is 
illogical.


Re: What the hell is wrong with D?

2017-09-20 Thread Jack Applegame via Digitalmars-d-learn
On Tuesday, 19 September 2017 at 19:54:02 UTC, Steven 
Schveighoffer wrote:

On 9/19/17 1:40 PM, EntangledQuanta wrote:


The first returns x + w/2 and the second returns w/2!


Did you mean (x + w) / 2 or x + (w / 2)? Stop being ambiguous!

-Steve


The best answer. :D


Re: What the hell is wrong with D?

2017-09-19 Thread nkm1 via Digitalmars-d-learn
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.


Ok, you win. I see now that you're very smart :)



Re: What the hell is wrong with D?

2017-09-19 Thread EntangledQuanta via Digitalmars-d-learn

On Wednesday, 20 September 2017 at 02:57:21 UTC, jmh530 wrote:
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...


Are you an idiot? Seriously, you must be. You just want to create 
drama instead of supply an actual logical argument(which I read 
your argument and it is pathetic). Show me where I threatened the 
guys life! Fucking moron. You must be some TSA goon or DHS 
wannabe.




Re: What the hell is wrong with D?

2017-09-19 Thread EntangledQuanta via Digitalmars-d-learn
On Wednesday, 20 September 2017 at 02:36:50 UTC, Jonathan M Davis 
wrote:
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:
>> [...]
>
> 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



But, of course, It's ok for him to come me an idiot. Let me 
quote, not that it matters, since you are biased and a hypocrite:


">> > If someone is too stupid to learn how precedence works, they
> should consider a different career instead of blaming 
> others."


But when I call him an idiot, I'm put in the corner.

I see how it works around here. What a cult!


Re: What the hell is wrong with D?

2017-09-19 Thread jmh530 via Digitalmars-d-learn
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...


Re: What the hell is wrong with D?

2017-09-19 Thread B4s1L3 via Digitalmars-d-learn
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.


Re: What the hell is wrong with D?

2017-09-19 Thread Jonathan M Davis via Digitalmars-d-learn
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



Re: What the hell is wrong with D?

2017-09-19 Thread EntangledQuanta via Digitalmars-d-learn
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 

Re: What the hell is wrong with D?

2017-09-19 Thread EntangledQuanta via Digitalmars-d-learn

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.


Re: What the hell is wrong with D?

2017-09-19 Thread rikki cattermole via Digitalmars-d-learn

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!



Re: What the hell is wrong with D?

2017-09-19 Thread Jesse Phillips via Digitalmars-d-learn
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.


Re: What the hell is wrong with D?

2017-09-19 Thread nkm1 via Digitalmars-d-learn
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.




Re: What the hell is wrong with D?

2017-09-19 Thread jmh530 via Digitalmars-d-learn
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;
instead of
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;
instead of
result = a > b ? x : y;
which kind of defeats the purpose.


Re: What the hell is wrong with D?

2017-09-19 Thread Neia Neutuladh via Digitalmars-d-learn
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.


Re: What the hell is wrong with D?

2017-09-19 Thread Brad Anderson via Digitalmars-d-learn
On Tuesday, 19 September 2017 at 19:16:05 UTC, EntangledQuanta 
wrote:

[snip]

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.


I have no doubt that had someone thought to propose addressing 
this when the language was new it would have been seriously 
considered and likely accepted (given how frequently this causes 
bugs). D tried to fix a lot of behavior from C that was bug prone 
but it didn't catch everything.


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.


Re: What the hell is wrong with D?

2017-09-19 Thread Steven Schveighoffer via Digitalmars-d-learn

On 9/19/17 1:40 PM, EntangledQuanta wrote:


The first returns x + w/2 and the second returns w/2!


Did you mean (x + w) / 2 or x + (w / 2)? Stop being ambiguous!

-Steve


Re: What the hell is wrong with D?

2017-09-19 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 19 September 2017 at 19:16:05 UTC, EntangledQuanta 
wrote:


()?: 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 sympathize that it was a difficult to find problem. Happens to 
me a lot. Nevertheless, I pretty much never use ternary operators 
because Matlab was my first language was it doesn't have them. 
I'm always writing out if() { } else { }. So it's not really an 
error that happens for me.


The point that others and myself were making about C is that your 
initial post was very critical of D and Walter. Unduly, IMO. You 
were blaming D for the problem, when it turns out that in 
virtually every language that uses this syntax it works this way 
(and I checked like 10, just to be sure). Harshly criticizing 
Walter for something that is a generally accepted way of doing 
things across many programming languages is unreasonable. D never 
promised to be the greatest language ever whose users never ever 
write any buggy code at all. It's aims are a bit more limited 
than that.


There's an easy solution to your problem: use more parentheses 
with conditional ternary operators.


Re: What the hell is wrong with D?

2017-09-19 Thread EntangledQuanta via Digitalmars-d-learn
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.












Re: What the hell is wrong with D?

2017-09-19 Thread Jesse Phillips via Digitalmars-d-learn
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.


Re: What the hell is wrong with D?

2017-09-19 Thread Ali Çehreli via Digitalmars-d-learn

On 09/19/2017 11:34 AM, Brad Anderson wrote:
> On Tuesday, 19 September 2017 at 18:17:47 UTC, jmh530 wrote:

>> Pretty sure it would be exactly the same thing in C...
>
> It is (and Java and C# and pretty much every other C style language
> though the nicer implicit conversion rules means it gets caught more
> easily). It is a big source of programmer mistakes. It comes up
> frequently in PVS Studio's open source analysis write ups.

Just a random Google find for some entertainment. :)


http://twistedoakstudios.com/blog/Post5273_how-to-read-nested-ternary-operators

  string result = i % 2 == 0 ? "a" : i % 3 == 0 ? "b" : i % 5 == 0 ? 
"c" : i % 7 == 0 ? "d" : "e";


Ali



Re: What the hell is wrong with D?

2017-09-19 Thread Brad Anderson via Digitalmars-d-learn

On Tuesday, 19 September 2017 at 18:17:47 UTC, jmh530 wrote:
On Tuesday, 19 September 2017 at 17:40:20 UTC, EntangledQuanta 
wrote:


Thanks for wasting some of my life... Just curious about who 
will justify the behavior and what excuses they will give.


Pretty sure it would be exactly the same thing in C...


It is (and Java and C# and pretty much every other C style 
language though the nicer implicit conversion rules means it gets 
caught more easily). It is a big source of programmer mistakes. 
It comes up frequently in PVS Studio's open source analysis write 
ups.


Re: What the hell is wrong with D?

2017-09-19 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 19 September 2017 at 17:40:20 UTC, EntangledQuanta 
wrote:


Thanks for wasting some of my life... Just curious about who 
will justify the behavior and what excuses they will give.


Pretty sure it would be exactly the same thing in C...


Re: What the hell is wrong with D?

2017-09-19 Thread Eugene Wissner via Digitalmars-d-learn
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