This is more of a "for fun" sort of thing, as it would be impractical to actually use this. I just want to satisfy my curiosity as to whether or not it's even possible.
I have a function...
function longAdd(a,b){
//computation here
return sum;
}
...which "adds" the values of a and b together as a string; meaning, it iterates through each character and adds them up. Thus, it can compute numbers which are greater than what could otherwise be achieved.
(for the purposes of this question, the actual code should not be relevant, so it is not included)
My question is: would it be possible to directly change the "+" operator to use this function? For instance,
c+d
anywhere in the code would essentially compute longAdd(c,d).
Any possible hacky ways to achieve this? For that matter, can the behavior of any operators be directly changed?
Note: Yes, I am aware this would screw up concatenation and big, numerical values would have to stay strings. This is just a concept I'm curious about.