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 17:58:43 PDT 2009
On Sat, 25 Apr 2009 19:11:57 -0400, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
> Robert Jacques wrote:
>> On Sat, 25 Apr 2009 18:04:32 -0400, Andrei Alexandrescu
>> <SeeWebsiteForEmail at erdani.org> wrote:
>> Also, I see a major logical problem with your proposal:
>> Given A single owner is required for deterministic destruction.
>> Then The array's owner is responsible for the deterministic
>> destruction.
>> Therefore When the array's owner goes out of scope, it must destruct
>> the array.
>> But Then How does a function return an array?
>
> My understanding is that you don't know how C++ and D value semantics
> work. It would be impossible to answer your (albeit good) question
> without first writing a tutorial on the topic, which unfortunately I
> don't have the time for.
I know how value semantics work. But
1) You haven't mentioned that T[new] has value semantics, only that you
were thinking about it.
2) Struct destructors are always called and don't get optimized away even
if the memory copy does. (i.e. I know there's a nice optimization to get
out of the extra copy, but I don't know how you'd do it in DMD currently).
>
>
> Andrei
More information about the Digitalmars-d
mailing list