More radical ideas about gc and reference counting

Rainer Schuetze via Digitalmars-d digitalmars-d at puremagic.com
Mon May 12 00:10:45 PDT 2014



On 12.05.2014 06:57, "Ola Fosheim Grøstad" 
<ola.fosheim.grostad+dlang at gmail.com>" wrote:
> On Sunday, 11 May 2014 at 20:45:08 UTC, Rainer Schuetze wrote:
>>
>>
>> On 11.05.2014 22:33, Walter Bright wrote:
>>>
>>>>> The Boehm collector cannot move objects around, the D one can.
>>>> Oh it can? Really?
>>>
>>> Yes. D, for example, requires that objects not be self-referential for
>>> this reason.
>>
>> I don't think the GC would have problems with fixing up internal
>> pointers to the object itself. self-referential is prohibited to allow
>> moving structures by memcpy, e.g. as return value.
>
> Does this mean that you cannot safely implement something as basic as a
> circular linked list?

Depends on your implementation, but I would not expect that the nodes of 
your linked list could be subject to being moved (mostly happens on the 
stack AFAICT), as pointers to the node from other nodes would become 
invalid, too.


More information about the Digitalmars-d mailing list