T.init for static arrays?

Walter Bright newshound1 at digitalmars.com
Sat Mar 13 12:13:26 PST 2010


Currently, given an array:

    alias T[3] A;
    A a;

the default initializer for A, A.init, is T.init. It is done this way 
for memory efficiency, as:

    a = A.init;

doesn't need to create an array for the rvalue. But it does cause 
generic programming problems, especially with the advent of static 
arrays now being passed by value rather than by ref.

So, I propose changing A.init from being T.init to being [T.init, 
T.init, T.init].

What do you think?



More information about the Digitalmars-d mailing list