On Saturday, 21 February 2015 at 18:30:18 UTC, Olivier Pisano wrote:
On Saturday, 21 February 2015 at 10:06:26 UTC, FrankLike wrote:
RAII(Resource Acquisition Is Initialization) is a good thing,will D plan to do it?

It's already here :


import std.stdio;

struct Test
{
    ~this() { writeln("RAII"); }
}

void main()
{
     Test t; // prints "RAII" when goes out of scope
}

He's maybe talking about reference counting because "owning" the resources is very faisable and simple (non gc objects are constructed in this() and destructed in ~this(), but the problem happends when you escape the owned reference as a raw pointer. At a time it may become dangling or even freed by another entity, e.g not the one which has initialized the thing.

The first reply is clearly about this (when weaselcat said "It becomes a bit tricky when you want class semantics with RAII"), because std RC is not for classes.

Reply via email to