A Refcounted Array Type

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Wed Feb 25 17:48:26 PST 2015


On Tuesday, February 24, 2015 01:44:07 Walter Bright via Digitalmars-d wrote:
> On 2/24/2015 1:32 AM, Jonathan M Davis via Digitalmars-d wrote:
> > The issue is that delete is considered @safe by the compiler,
>
> I thought more people would be interested in how to do a memory safe reference
> counted container.

Oh, I think that that there's definitely something there and that we should
be interested. I don't think that either Andrei or I were trying to take
away from that. It's just that code showed a problem in that delete was
considered @safe when it should be @system, so Andrei pointed that out, and
then I agreed with him and pointed out that delete was really supposed to
have been deprecated by now anyway. But the concept is perfectly valid, and
delete can be replaced with destroy and core.memory.GC.free for the same
effect without actually needing delete, so it'll still work even if delete
is finally deprecated - though honestly, I would think that if you're going
to be doing manual memory management, it would just be better to use malloc
and free and avoid the GC altogether (though if the element type contains
any references or pointers, you probably need to tell the GC about the
memory so that it can scan it).

- Jonathan M Davis



More information about the Digitalmars-d mailing list