proposal for general dup function

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Dec 10 12:10:25 PST 2012


On 12/10/12 2:54 PM, Jacob Carlborg wrote:
> On 2012-12-10 20:46, Andrei Alexandrescu wrote:
>
>> Just like Dan I thought it can be done but actually ownership is
>> impossible to establish in general. Consider:
>>
>> class List(T) {
>> List next;
>> T payload;
>> ...
>> }
>>
>> versus
>>
>> class Window {
>> Window parent;
>> ...
>> }
>>
>> It's pretty obvious from the name that duplicating a List would entail
>> duplicating its tail, whereas duplicating a Window would entail just
>> copying the reference to the same parent. However, at the type level
>> there's no distinction between the two members.
>
> I'm not sure, why wouldn't you want to copy the parent window as well?

You want to create a new window with the same parent. At the top level 
there's one desktop window, and probably having two would be odd.

Andrei



More information about the Digitalmars-d mailing list