The Many Faces of D - slides

Max Samukha spambox at d-coding.com
Mon Oct 4 12:59:55 PDT 2010


On 10/04/2010 10:47 PM, Simen kjaeraas wrote:
> Max Samukha <spambox at d-coding.com> wrote:
>
>> On 10/03/2010 10:47 PM, Walter Bright wrote:
>>>
>>> In D, all struct (and class) instances are, by definition, movable using
>>> memcpy().
>>>
>>
>> Structs are ok. Classes are not. Do you really want to forbid this use
>> case:
>>
>> class A
>> {
>> private A _parent;
>> private A[] _children;
>>
>> this(A parent)
>> {
>> if (parent !is null) {
>> _parent = parent;
>> _parent._children ~= this;
>> }
>> }
>> }
>>
>> auto parent = new A;
>> auto child = new A(parent);
>>
>> ?
>
> I don't see how that is incompatible with what Walter said. Of course
> one would need to update pointers to the moved classes.
>

He said "movable using memcpy()". He didn't say anything about adjusting 
pointers. A moving GC should and will adjust pointers, but I don't see 
how the memcpy() is relevant here.


More information about the Digitalmars-d mailing list