expression templates vs D arrays
sandford at jhu.edu
Wed Dec 7 23:11:08 PST 2011
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?
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.
More information about the Digitalmars-d