Lars T. Kyllingstad wrote:
Don wrote:
Andrei Alexandrescu wrote:
Walter Bright wrote:
Andrei Alexandrescu wrote:
This also reminds me that the entire operator overloading feature must be thrown away and redesigned.

:-(

It's run its course like an old BMW. We need to do new things, and bolting them on what we have won't work.

Andrei

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.


That is true. There is, for instance, a good reason why the basic BLAS matrix multiplication routine calculates

  a A B + b C        (a,b: scalars; A,B,C: matrices)

instead of just AB.

Would/could one could gain something, performance-wise, by having such "expression overloading" as a built-in feature of the language itself, rather than as a library?

BLADE has already shown that it is possible to do stuff like this in a library, but I think it goes without saying that if it was built into the language the syntax could be made considerably nicer. Compare:

  auto m = MatrixOp!("a*A*B + b*C")(aVal, bVal, aMtrx, bMtrx, cMtrx);

  auto m = a*A*B + b*C;

If D could do this, I think it would become the next FORTRAN. :)

-Lars

Actually, this has already been done in C++: http://flens.sourceforge.net/ It should be possible to port it to D...

                Jerome
--
mailto:jeber...@free.fr
http://jeberger.free.fr
Jabber: jeber...@jabber.fr

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to