Following up from my previous question, why is CShell so different from C?
- 4 - 3 + 1 = 2 in C.
- 4 - 3 + 1 = 0 in CShell.
Any ideas?
Following up from my previous question, why is CShell so different from C?
Any ideas?
Different people wrote the products, and they had different views of how to handle the calculations. And since the C Shell was written second, I think they're at fault for not following the lead of the nominal parent language.
Generally the traditional notation is left to right (left associative) in human papers. So for humans (which used this notation long before c, csh or even any notion of computers):
4 - 3 + 1 = (4 - 3) + 1 = 1 + 1 = 2
Why? I guess that the best answer is because. It's the same as with driving left or right side of road. It really doesn't matter which side as long as everyone uses the same.
IMHO the csh is wrong as it is counter-intuitive. Possibly it was an error (they wanted left associative but coded wrongly) and become legacy as other things already depeneded on this.