d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Need Help. > Confused And Scared.
Prev123Next
Add Reply New Topic New Poll
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Nov 4 2014 04:14am
Quote (killg0re @ Nov 3 2014 12:53pm)
:^)


lol, those were pretty good
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Nov 4 2014 07:10am
Quote (killg0re @ Nov 3 2014 12:29pm)
https://i.imgur.com/CGnc5NF.png

https://i.imgur.com/rtBHfZE.jpg


... What are they talking about? I see nothing wrong with that program snippet syntactically, why do they say it won't compile?

Code
#include <iostream>

using namespace std;

int main()
{
int Tweeter, Gamergater;
int Tweet, Negative;

if(Tweeter = Gamergater)
cout << "Block." <<endl;
else
if (Tweet = Negative)
cout << "Block" << endl;

}


This post was edited by Minkomonster on Nov 4 2014 07:11am
Member
Posts: 62,215
Joined: Jun 3 2007
Gold: 9,039.20
Nov 4 2014 08:18am
Quote (Minkomonster @ Nov 4 2014 07:10am)
... What are they talking about? I see nothing wrong with that program snippet syntactically, why do they say it won't compile?

Code
#include <iostream>

using namespace std;

int main()
{
    int Tweeter, Gamergater;
    int Tweet, Negative;

    if(Tweeter = Gamergater)
        cout << "Block." <<endl;
        else
            if (Tweet = Negative)
                cout << "Block" << endl;

}


Strange, does your compiler have the womyn extension to compensate for poor syntax?

Since assignment doesn't exist within an if, maybe it just assumes you're retarded and meant something else.

Not even Python does that. :rofl:



At least it produces warnings.

Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Nov 4 2014 09:38am
Warning != syntax error

And assignment does exist within an if which is why it is perfectly valid c code. The warning came after. The reason being back in the day before coding standards were more established, c was focused purely on performance. And there are cases where doing assignments inside the if condition resulted in code that was more performant.

The warning came later to let newbie c++ programmers know that they might have botched their comparison because they don't understand the difference between assignment and comparison and also don't understand that c syntax allows for both in an if.

Anything else?

This post was edited by Minkomonster on Nov 4 2014 09:50am
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Nov 4 2014 10:16am
Quote (Minkomonster @ Nov 4 2014 11:38am)
Warning != syntax error

And assignment does exist within an if which is why it is perfectly valid c code. The warning came after. The reason being back in the day before coding standards were more established, c was focused purely on performance. And there are cases where doing assignments inside the if condition resulted in code that was more performant.

The warning came later to let newbie c++ programmers know that they might have botched their comparison because they don't understand the difference between assignment and comparison and also don't understand that c syntax allows for both in an if.

Anything else?


Don't hate on the coding illiterate. :(
Member
Posts: 62,215
Joined: Jun 3 2007
Gold: 9,039.20
Nov 4 2014 10:18am
Quote (AbDuCt @ Nov 4 2014 10:16am)
Don't hate on the coding illiterate. :(


This, we're people too.



This post was edited by killg0re on Nov 4 2014 10:18am
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Nov 4 2014 11:12am
Quote (killg0re @ Nov 4 2014 11:18am)
This, we're people too.

https://i.imgur.com/BZomtZO.jpg


I am not hating on anyone. I was explaining how the assumption that there was a syntax error was wrong. And further explaining that your attempt to troll me by calling my compiler a woman and compensating for my mental capacity was also wrong. And further explaining that your defense of those who called that person out for her tweet for her compliation errors was dead wrong in every way possible. Sure, the code does not follow standard practices and there definitely are some logic errors.but there are NOT syntax errors.
Member
Posts: 62,215
Joined: Jun 3 2007
Gold: 9,039.20
Nov 4 2014 12:08pm
Quote (Minkomonster @ Nov 4 2014 11:12am)
I am not hating on anyone. I was explaining how the assumption that there was a syntax error was wrong. And further explaining that your attempt to troll me by calling my compiler a woman and compensating for my mental capacity was also wrong. And further explaining that your defense of those who called that person out for her tweet for her compliation errors was dead wrong in every way possible. Sure, the code does not follow standard practices and there definitely are some logic errors.but there are NOT syntax errors.


I don't have much experience in C/C++ didn't realize it was so forgiving for minor syntax errors. The syntax is incorrect though, the compiler recognizes this and warns you, so it is still an error even if it doesn't crash.

Python cuts dead if you mix up == and = operators in the syntax, many other languages do too.

Since operators are part of the code arrangement, they are still technically part of the syntax, though the compiler seems to not care if about this error and only passes warnings.

Your real mistake was taking their comment literally, it visually had syntax mistakes and was called out immediately, it is not like anyone actually tried to run her garbage twitter troll bait. Finally, the comment "0/0 WOULD NOT COMPILE" is a play on the popular internet-idiom would not fuck, which has nothing to do with actually compiling the code but with the posters disgust at the terrible syntax.

Why do I have to explain this?

Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Nov 4 2014 01:36pm
Quote (killg0re @ Nov 4 2014 01:08pm)
I don't have much experience in C/C++ didn't realize it was so forgiving for minor syntax errors. The syntax is incorrect though, the compiler recognizes this and warns you, so it is still an error even if it doesn't crash.

Python cuts dead if you mix up == and = operators in the syntax, many other languages do too.

Since operators are part of the code arrangement, they are still technically part of the syntax, though the compiler seems to not care if about this error and only passes warnings.

Your real mistake was taking their comment literally, it visually had syntax mistakes and was called out immediately, it is not like anyone actually tried to run her garbage twitter troll bait. Finally, the comment "0/0 WOULD NOT COMPILE" is a play on the popular internet-idiom would not fuck, which has nothing to do with actually compiling the code but with the posters disgust at the terrible syntax.

Why do I have to explain this?


You keep saying syntax errors. There are NO syntax errors. Warnings are there to catch potential logical errors. The syntax is 100% valid. 0 errors. Logically there may be discrepancies. Hence the Warning. Are you getting it now?
Member
Posts: 62,215
Joined: Jun 3 2007
Gold: 9,039.20
Nov 4 2014 01:38pm
Quote (Minkomonster @ Nov 4 2014 01:36pm)
You keep saying syntax errors. There are NO syntax errors. Warnings are there to catch potential logical errors. The syntax is 100% valid. 0 errors. Logically there may be discrepancies. Hence the Warning. Are you getting it now?


If the syntax is incorrect, even if it compiles, it is still an error or else the compiler wouldn't have to warn you of the syntax being incorrect.
Go Back To Programming & Development Topic List
Prev123Next
Add Reply New Topic New Poll