T.init for static arrays?
Steven Schveighoffer
schveiguy at yahoo.com
Mon Mar 15 05:50:29 PDT 2010
On Sat, 13 Mar 2010 15:13:26 -0500, Walter Bright
<newshound1 at digitalmars.com> wrote:
> 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?
Is that going to allocate heap data as the current array literal does? If
so, it's a step backwards. It needs to be ROM data.
-Steve
More information about the Digitalmars-d
mailing list