static array literal syntax request: auto x=[1,2,3]S;

Don Clugston dac at nospam.com
Fri Jun 15 00:09:48 PDT 2012


On 10/06/12 23:43, Jonathan M Davis wrote:
> On Sunday, June 10, 2012 23:23:57 Mehrdad wrote:
>> I honestly don't see the POINT of having a "dynamic array
>> literal".
>>
>> What's the point of making the literals dynamic?
>>
>> They should all be static, and only converted to dynamic if
>> necessary from the context.
>>
>> But I really don't see the benefit of allocating them on the heap
>> just because we can... perhaps someone can enlighten me?
>
> In the vast majority of cases where an array literal is used, it's assigned to
> a dynamic array.

I doubt that very much. I know it's not true in my code, I use array 
literals almost exclusively for immutable values.
Usually if you are initializing an array, where you will modify the 
elements later, you want all values to be the same.

I argued that array literals should be immutable, just as string 
literals are. But I lost.


More information about the Digitalmars-d mailing list