If T[new] is the container for T[], then what is the container for T[U]?
Robert Jacques
sandford at jhu.edu
Sat Apr 25 07:58:26 PDT 2009
On Sat, 25 Apr 2009 09:16:39 -0400, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
> Stewart Gordon wrote:
>> Andrei Alexandrescu wrote:
>>> It looks we can't make it with only T[]. We need a genuine container
>>> type, and T[new] was suggested.
>> <snip>
>> What do you mean by a "genuine container type"?
>
> One with capacity and probably value semantics.
>
> Andrei
First, capacity is only static (i.e. can be included in the array as you
suggest) for free-list based allocation. Which is _only_ used by malloc
and mark-sweep GCs. And I'm really hoping Leandro gives us something
better than mark-sweep.
Second, if people want value semantics, they can already use .dup or a[] =
... when needed. Adding value semantics to arrays seems to me like a
recipe for unintended poor performance by new to D programmers (who don't
know) and experienced ones (who make a hard to find typo) a like. (I can
see that value semantics for static arrays might be useful i.e.
foo(real[4] vec), but I don't see a major need for dynamic vectors to have
value semantics and every reason they shouldn't, i.e. foo(real[]
big_image). Counter examples are desired and welcome.)
More information about the Digitalmars-d
mailing list