java and the laws of arithmetics
Apr. 14th, 2005 11:32 amAs Stepanov noted once, associative laws are the basis of enabling computational parallellism.
Lessons learned, and comments in java libraries all tell you to obey the laws - equality, e.g., must be symmetric, reflexive, transitive; monotonous math functions must be monotonous (hence adoption of IEEE arithmetics as opposed to what fast and cheap math processors offer), addition and multiplication must be "strictly" commutative and associative, etc; and also, no, NO operators overriding. (Would not it be cool to have an operator for equals()? is not it binary?)
Then, all of a sudden, you discover the obvious truth that String Addition Is Not Commutative...
So, what's the point of all this fuss about the rules? String addition is not an addition, friends. It is not.
Lessons learned, and comments in java libraries all tell you to obey the laws - equality, e.g., must be symmetric, reflexive, transitive; monotonous math functions must be monotonous (hence adoption of IEEE arithmetics as opposed to what fast and cheap math processors offer), addition and multiplication must be "strictly" commutative and associative, etc; and also, no, NO operators overriding. (Would not it be cool to have an operator for equals()? is not it binary?)
Then, all of a sudden, you discover the obvious truth that String Addition Is Not Commutative...
So, what's the point of all this fuss about the rules? String addition is not an addition, friends. It is not.