bearophile pisze:
aarti_pl:
T opInfix(string op)(T rhs) { ... }
T opPrefix(string op)(T rhs) { ... }
T opPostfix(string op)(T rhs) { ... }
So you can use opInfix to define operators like a ~~ b :-)
Exactly. But the question is if you *REALLY* need it :-) But IMHO the
answer is up to designer.
Now you just need a way to define operator precedence level, with an int number
in 0-14 and you're done (I don't think you need to specify operator
associativity if left-to-right/right-to-left) :-)
T opInfix(string op, int prec)(T rhs) { ... }
There programming languages that allow to specify operator precedence level
too, but I think this is overkill in D.
I agree. That's too much.
Regarding operators, in D they are named according to their purpose and not
according to their look, and I think this is a good idea. But opDollar doesn't
follow that, so isn't a name like opEnd better?
I think that proposed names exactly reflect the meaning. So I would say
it is perfectly consistent with D convention.
Bye,
bearophile