expression templates vs D arrays

Timon Gehr timon.gehr at gmx.ch
Thu Dec 8 04:16:46 PST 2011


On 12/08/2011 08:55 AM, Walter Bright wrote:
> On 12/7/2011 11:11 PM, Robert Jacques wrote:
>> On Wed, 07 Dec 2011 23:27:41 -0500, Jay Norwood <jayn at prismnet.com>
>> wrote:
>>
>>> I've been reading about the use of expression templates in this blitz
>>> page,
>>> which provides arrays implemented by c++ templates. They have some
>>> convenient
>>> features, such as array initialization with auto-incrementing array
>>> index
>>> values in the expressions and applying a cast operator to an entire
>>> array
>>> within an expression. Do D built-in array operations and initialization
>>> include these type of features, or would you need to create some
>>> similar D
>>> template implementation to guarantee the efficient expression
>>> evaluation and
>>> similar initialization features?
>>>
>>> http://www.oonumerics.org/blitz/docs/blitz_3.html#SEC80
>>>
>>
>> Built-in? No, not everything. But std.range, std.array and
>> std.algorithm have a
>> lot of the convenience features you're looking for. Actual D array
>> operations,
>> i.e. x[] = y[] + z[] * b;, are more efficient than expression templates.
>> Currently, what you can do in an array op is somewhat limited, but
>> generalization, i.e. x[] = sin(iota(0,x.length)[]) + y[] is on Don's
>> todo list.
>
> I'll add that you can do expression templates in D, but there's no point
> to them.

Expression templates in D are syntactically more limited because it is 
impossible to overload the 'not' and comparison operators. Why is there 
no point to them?


More information about the Digitalmars-d mailing list