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

Steven Schveighoffer schveiguy at yahoo.com
Mon Jun 11 03:57:49 PDT 2012


On Sun, 10 Jun 2012 20:08:53 -0400, Mehrdad <wfunction at hotmail.com> wrote:

>>> Type deduction.
>>
>> Exactly. And if they need to be assigned to a static array, then the  
>> compiler
>> can automatically do what it needs to do to avoid the extra heap  
>> allocation.
>>
>> - Jonathan M Davis
>
>
> "Type deduction"?  o.O
> I don't understand... could someone give me an example of what would  
> break if we used the rule I suggested?

Anything that uses type deduction?  Most of the time, you do *not* want a  
static array, especially for template functions that use IFTI.

Note that D1 was like this, [1,2,3] was auto-typed to int[3u].  It was a  
constant source of pain that I would not like to revisit.  Especially  
since static arrays are now passed by value.

-Steve


More information about the Digitalmars-d mailing list