resizeable arrays: T[new]
Oskar Linde
oskar.lindeREM at OVEgmail.com
Fri Jun 8 02:46:28 PDT 2007
Walter Bright skrev:
> Oskar Linde wrote:
>> Walter Bright skrev:
>>
>>> [...] the difference between static arrays and dynamic arrays is very
>>> large. For one thing, static arrays are passed by value, and dynamic
>>> arrays by reference.
>>
>> This sounds intriguing. Does this mean that static arrays will be
>> passed by value in D 2.0?
>
> Yes.
That is wonderful! Another wrinkle ironed out.
>> Will string literals become dynamic (invariant) arrays instead of
>> static too?
>
> They'll be invariant static arrays.
Yeah, I got that a few minutes after posting from another post. My only
(minor) concern here was the potential performance penalty of passing
string literals to simple template functions, like
void foo(T)(T x) {...},
but there are plenty of ways to deal with that. For example, since they
are invariant, I guess they could be passed by reference behind the
scenes anyway.
/Oskar
More information about the Digitalmars-d-announce
mailing list