Additional Binary Operators

H. S. Teoh hsteoh at quickfur.ath.cx
Mon Mar 4 15:23:46 PST 2013


On Tue, Mar 05, 2013 at 12:17:06AM +0100, Marco Leise wrote:
> Am Mon, 04 Mar 2013 23:36:29 +0100
> schrieb "bearophile" <bearophileHUGS at lycos.com>:
> 
> > jerro:
> > 
> > > Of course, expression templates should also be much easier
> > > to implement in D than they are in C++.
> > 
> > I don't remember seeing them implemented in D, so far.
> > 
> > Bye,
> > bearophile
> 
> It's not as easy to do without C++'s convoluted constructor
> lookup rules. The clean approach of D makes it impossible to
> call a constructor implicitly like they do on the Wikipedia
> page about expression templates.
> But the approach with a small DSL looks ok, too. Not quite as
> seamless as the C++ version though.
[...]

The advantage of using DSLs is that you are free of syntax constraints
in the hosting language. For example, you can add different symbols for
dot product, cross product, transpose operator, etc., without being
restricted by the operators that D allows you to overload. D's mixins
allow you to transform such expressions into D code in non-trivial ways
to achieve maximum performance in spite of the ease of writing it.


T

-- 
Shin: (n.) A device for finding furniture in the dark.


More information about the Digitalmars-d mailing list