How macroish would that be? It'd be fairly simple if all the operator declarations are strictly lexical, just like cpp macros so that they would have to reside in some header file. Otherwise you'd have to figure out all sorts of rules regarding how the operators are looked up and what should happen if they conflict between different classes and/or modules.
/ Martin Stjernholm, Roxen IS
Previous text:
2003-05-15 20:48: Subject: top level infix operators
Hmm... how about having some sort of macro-ish construct for this?
SML has something similar (although I don't know the itty-bitty details). The idea is that you declare a token as an infix operator and assign it a function.
An example with a minimal pow operator:
int my_pow(int base, int power) { return pow(base,power); } infix "**" * my_pow; // or infix("**", 4 , my_pow); // 4 is how hard it binds in comparison to other operators
My thought is that this code
int foo = 2**3;
is expanded to
int foo = pow(2,3);
or rather the unoptimized case of
int foo = (pow(2,3));
/ Peter Lundqvist (disjunkt)