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

Rainer Deyke rainerd at eldwood.com
Fri Jul 10 13:14:47 PDT 2009


Don wrote:
> Indeed, I even think that the concept of operator overloading is wrong.
> In C++, operator overloading was just for syntax sugar. That's wrong:
> pretty much everything that you want overloaded operators for, is
> performance-critical. And that implies you need to deal on the level of
> complete expressions, not individual operations.

I disagree for two reasons:

1. Operator syntax /is/ just syntax sugar for function calls, which is a
concept orthogonal with expression-level optimization.  Consider the
following expressions:
  a + b + c
  add(add(a, b), c)
If one of these is reduced to a single function call, both should be.

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


-- 
Rainer Deyke - rainerd at eldwood.com



More information about the Digitalmars-d mailing list