Additional Binary Operators
Artur Skawina
art.08.09 at gmail.com
Tue Mar 5 04:40:19 PST 2013
On 03/05/13 00:23, H. S. Teoh wrote:
> 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
They are trivial to implement, i even gave you an example in the past:
http://forum.dlang.org/post/mailman.1195.1344699986.31962.digitalmars-d@puremagic.com
>> 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
One problem with string-based DSLs is scoping - they only work properly
when mixed in into the current scope.
auto c = mixin(myDSL!"a?:+:b");
mixin myDSL!("c", "a?:+:b");
mixin (myDSL!("c", "a?:+:b"));
// etc
is sometimes enough, but often the code would be clearer w/o the mixin.
artur
More information about the Digitalmars-d
mailing list