Non-Initialized Dynamic Arrays Construction

Francesco Cattoglio francesco.cattoglio at gmail.com
Mon Feb 24 04:15:20 PST 2014


On Monday, 24 February 2014 at 12:08:31 UTC, Nordlöw wrote:
> On Monday, 24 February 2014 at 11:29:39 UTC, bearophile wrote:
>> TheFlyingFiddle:
>>
>>> http://dlang.org/phobos/std_array.html#.uninitializedArray is 
>>> what you want.
>
> Wouldn't it be nice to have some kind of syntactic sugar for 
> this similar to what we have for static arrays?
>
> BTW: Why isn't simply the following allowed?
>
>     int n = 3;
>     int[n] = void;
>
> Is it too easy to confuse with static array syntax?

to me, it also looks like you are creating an array of ints, and 
trying to void it's reference. I honestly don't like the look of 
it either.
Something like "auto arr = new float[n].void" would fit better, 
but still looks horrible IMO :)


More information about the Digitalmars-d-learn mailing list