Original Post
As some might know, I dabble around with a progamming language. And I would like community thoughts about operator overloading. Function declarations in the language are a little more free form than in some languages. Normal C-ish looking methods are there:
f() => void {...} // f()
f(int x) => int {...} // f(5)
f(int x, int y) => bool {...} // f(5,5)
So are functional-ish looking methods:
f (int x) (int y) => bool {...} // f 5 5
So are infix operators:
(int x) op (int y) => bool {...} // 5 op 5
And the language allows such constructs arbitrarily (except one of the first two bits must be a simple identifier):
(int x) foo (int y) bar (int z) => void {...} // 5 foo 6 bar 7
foo bar => void {...} // foo bar
So, it would be useful to allow symbols in place of common identifiers:
(int x) + (int y) => int {...} // 2+2
++(int x) => int {...} // ++x
What do you think the limitation on this should be? ++(int x) is tricky for example. Should ++ be parsed out as its own operator, or should the individual symbols be parsed out separately and behave like foo foo (int x)? If they're parsed out individually, should the language limit chaining; that is prevent someone from making the operator !%^+++*&^? If they're not parsed out individually, then I'd need to make some list of overloadable operators. What should be included there then? Or is operator overloading evil incarnate and I should forget the whole thing?