[Issue 124] Enhancement: Operator overloading without temporaries

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jun 27 20:30:21 PDT 2007


http://d.puremagic.com/issues/show_bug.cgi?id=124





------- Comment #4 from davidl at 126.com  2007-06-27 22:30 -------
yah, it'a great idea. if opSubAssign_r could be automatically deduced from
opSubAssign it would be even greater. 
Then opAddAssign_r would leave in compiler internal.
while the possibilities are there:

typeof(this) opSubAssign(this, oper)  
opSubAssign_r would simply as following:
tyepof(this) opSubAssign_r(oper, this)
and also opDivAssign_r

any non-commutative operand would need to have this reverse op. and compiler
only need to consider non-commutative situation

as we can see in common case, integer , float type , sub and div operators are
not commutative.

Shall we introduce some *commutative* keyword to let the compiler know if it's
okay to call the original op overloading. If not, the compiler would try to
call the op_r which is deducing from op overloading.


-- 



More information about the Digitalmars-d-bugs mailing list