dsgrue3 said:
That's a variable declaration, I'm done talking about this. |
Ironically, a major stumbling block for beginners in computer science is that they have a muddled mental model of variable assignment. When they see an assignment statement like "x=2", a part of them confuses this with the equals sign in math. In mathematical writing, "x=2" is not a variable declaration but merely states that the two sides are equal (one declares a variable by using words like "let", "define", or sparingly, the shorthand ":=" symbol). So the sentence "x=2" holds no more or less information than "2=x".
[One exception to this claim: in my own area of math, we often (ab)use the = sign in a way that is not symmetric when describing error estimates. We would write "x = O(n)" to mean that x is bounded by a multiple of n, when formally it would be more appropriate to use element inclusion. Consequently, even if one has "x = O(n)" and "y = O(n)" one cannot deduce that "x=y".]
By contrast, in (declarative) programming languages it makes perfect sense to write "x=2" followed later by "x=3", which is mindboggling to a certain number of beginning students. And of course in most languages "2=x" would be an illegal assignment.







