On Friday, 12 June 2015 at 01:55:15 UTC, Wyatt wrote:
From the outset, my thought was to strictly define the set of
(eight or so?) symbols for this. If memory serves, it was
right around the time Walter's rejected wholesale user-defined
operators because of exactly the problem you mention.
(Compounded by Unicode-- what the hell is "2 🐵 8" supposed to
be!?) I strongly suspect you don't need many simultaneous
extra operators on a type to cover most cases.
-Wyatt
I actually thought about it more, and D does have a bunch of
binary operators that no ones uses. You can make all sorts of
weird operators like +*, *~, +++, ---, *--, /++, ~~, ~-, -~,
>>>--, &++, ^^+, in++, |-, %~, ect...
void main(string[] args){
test a;
test b;
a +* b;
}
struct test{
private struct testAlpha{
test payload;
}
testAlpha opUnary(string s : "*")(){
return testAlpha(this);
}
void opBinary(string op : "+")(test rhs){
writeln("+");
}
void opBinary(string op : "+")(testAlpha rhs){
writeln("+*");
}
}