Proposal: Operator overloading without temporaries

Oskar Linde oskar.lindeREM at OVEgmail.com
Tue Mar 28 02:02:18 PST 2006


I fully support this proposal. It makes sense to place stricter semantic 
requirements on overloaded operators. I can not see any problems. You 
seem to have everything covered. What restrictions should the compiler 
placed on the operator overloading signatures? Should it for instance be 
illegal to define an opAdd with a different return type than opAddAssign?

Don Clugston wrote:

> In C++, there are libraries like Blitz++ which use complicated 
> expression templates in order to avoid these creating these temporaries, 
> and provide performance comparable with FORTRAN. I think D can do much 
> better...

Expression templates would still be useful for other cases though. 
Consider: (A * B) % C.
Here, expression templates could allow evaluating a much more efficient 
modMul(A,B,C). Expression templates could also help writing less complex 
but still efficient code by allowing lazy evaluation.

/Oskar



More information about the Digitalmars-d mailing list