How to initialize static arrays with variable data
Steven Schveighoffer
schveiguy at yahoo.com
Fri Feb 19 09:28:20 PST 2010
On Fri, 19 Feb 2010 12:15:20 -0500, bearophile <bearophileHUGS at lycos.com>
wrote:
> Steven Schveighoffer:
>
>> It would be nice to allow this:
>> int[3] x = [a, b, c];
>
> This is allowed now.
Yes, but 1) it allocates the literal on the heap and then throws it away,
and 2) it would not be allowed if array literals are only allowed to be
immutable. I'm speaking from the context assuming that array literals are
made to be immutable by default.
-Steve
More information about the Digitalmars-d
mailing list