by Tdarcos » Fri Sep 14, 2012 3:29 am
Ice Cream Jonsey wrote:Tdarcos wrote:Like the use of the = sign in comparisons exclusively as a comparator. Some people like the idea that = is always used as an assignment operator, but I think there is no good reason to do an assignment in an if statement. Every other language that uses = in comparisons and = in assignment knows enough to tell the difference and people have no problem knowing the difference
Ben and I disagreed on that point! We totally disagreed. Clearly, Ben is a hapless lunatic living in a world he never made.
I think it's pretty good for a language found on the goddamn street.
I mean, seriously, even in Basic, even a 10-year-old writing a simple program knows the difference between
And realizes that = in the second statement means a comparison, not an assignment.
Pascal, on the other hand, does something a bit elegant to solve the problem, = is always a comparator, they use becomes, := for assignment. Wirth simply chose a different symbol the way Kernigan and Richie chose = to always mean assignment and == for comparison. I think wirth's solution to the problem, if you needed to be able to distinguish between = as assignment and = as comparison and don't want to have the compiler figure it out, is a better choice, but it's a matter of taste how you do it. It would have been far better if C had done it backward, always use = for comparison and == for assignment if they couldn't figure out how to separate the difference (a function Basic interpreters and compilers did back in 1966.)
I think Wirth would have had a better argument on using a dual symbol for assignment, Pascal was designed as a single-pass language and the compiler was able to scan the program once. So the compiler had to be simpler and thus maybe the tradeoff had to be made. I don't think C compilers were ever one pass.
But it still an important point that 4 years before C existed, the ability to distinguish between = as comparison and = as assignment had been solved in Basic.
[quote="Ice Cream Jonsey"][quote="Tdarcos"]Like the use of the = sign in comparisons exclusively as a comparator. Some people like the idea that = is always used as an assignment operator, but I think there is no good reason to do an assignment in an if statement. Every other language that uses = in comparisons and = in assignment knows enough to tell the difference and people have no problem knowing the difference[/quote]
Ben and I disagreed on that point! We totally disagreed. Clearly, Ben is a hapless lunatic living in a world he never made.
I think it's pretty good for a language found on the goddamn street.[/quote]
I mean, seriously, even in Basic, even a 10-year-old writing a simple program knows the difference between
[code]
100 A=5
110 IF A=5 THEN
[/code]
And realizes that = in the second statement means a comparison, not an assignment.
Pascal, on the other hand, does something a bit elegant to solve the problem, = is always a comparator, they use becomes, := for assignment. Wirth simply chose a different symbol the way Kernigan and Richie chose = to always mean assignment and == for comparison. I think wirth's solution to the problem, if you needed to be able to distinguish between = as assignment and = as comparison and don't want to have the compiler figure it out, is a better choice, but it's a matter of taste how you do it. It would have been far better if C had done it backward, always use = for comparison and == for assignment if they couldn't figure out how to separate the difference (a function Basic interpreters and compilers did back in 1966.)
I think Wirth would have had a better argument on using a dual symbol for assignment, Pascal was designed as a single-pass language and the compiler was able to scan the program once. So the compiler had to be simpler and thus maybe the tradeoff had to be made. I don't think C compilers were ever one pass.
But it still an important point that 4 years before C existed, the ability to distinguish between = as comparison and = as assignment had been solved in Basic.