std.container: fork in the road

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Wed Jun 17 10:41:40 PDT 2015


On 6/17/15 8:17 AM, rsw0x wrote:
> On Wednesday, 17 June 2015 at 15:03:40 UTC, Andrei Alexandrescu wrote:
>> On 6/17/15 2:59 AM, "Marc =?UTF-8?B?U2Now7x0eiI=?= <schuetzm at gmx.net>"
>> wrote:
>>>
>>> I think this decision should be left to the end-user. A container that
>>> supports only RC is just as bad as one that supports only GC. Instead,
>>> use SList!T or SList!(Unique!T) or SList(RefCounted!T) as appropriate.
>>>
>>> All internal metadata, on the other hand, should be treated as owned by
>>> the container. Calling clear() or removing individual elements needs to
>>> destroy the associated meta data, which in turn will correctly call the
>>> payload's (e.g. RefCounted!T or Unique!T) destructor if it has one.
>>
>> Yah, management strategy refers to the metadata. -- Andrei
>
> Do you plan on std.collections being usable both with and without the GC?

Collections are a perfect candidate for reference counted management.

(a) Orderly structure so the likelihood of cycles is arguably lower than 
for arbitrary object models;

(b) "Heavy", i.e. collections tend to be large enough to warrant care 
with allocation and deallocation.


-- Andrei


More information about the Digitalmars-d mailing list