Can we fix reverse operator overloading (opSub_r et. al.)?

BCS ao at pathlink.com
Fri Jul 10 13:24:37 PDT 2009


Reply to Rainer,

> 2. Expression-level optimization is the compiler's job, not the
> programmer's.
> 

Some (many?) of the interesting optimizations that can be applied to expressions 
with overloaded operators are not algebraic in nature.

Many of the use cases for operator overloading don't work if the compiler 
is allowed to assume all the same identities it can for scalars (e.g. the 
transitive identity doesn't hold for matrix math).

Unless you wan to make a way for the programmer to both add and remove expression 
level optimizations, and require an optimization engine powerful enough to 
use them, you can't do optimization of expressions with overloaded operators 
purely in the compiler.





More information about the Digitalmars-d mailing list