A Refcounted Array Type

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Tue Feb 24 01:32:21 PST 2015


On Monday, February 23, 2015 23:02:03 Walter Bright via Digitalmars-d wrote:
> On 2/23/2015 9:59 PM, Jonathan M Davis via Digitalmars-d wrote:
> > And delete is supposed to have been deprecated ages ago, but yeah, it
> > _definitely_ shouldn't be considered @safe.
>
> Managing memory always is going to be unsafe. The idea is to encapsulate that,
> which RCArray shows how to do.

That's fine. The issue is that delete is considered @safe by the compiler,
not with the idea of RCArray. This code shouldn't compile:

void main() @safe
{
    auto i = new int(5);
    delete i;
}

and it does. Of course, delete is supposed to have been deprecated, but no
one has gotten around to doing it. So, maybe that's why no one made it so
that it was treated correctly with regards to @safe.

- Jonathan M Davis



More information about the Digitalmars-d mailing list