forcing "@nogc" on class destructors
via Digitalmars-d
digitalmars-d at puremagic.com
Wed Jan 28 01:51:08 PST 2015
On Wednesday, 28 January 2015 at 02:33:11 UTC, Jerry Morrison
wrote:
> Sorry, I don't understand the question. I expect LIFO for
> freeing structs on the stack.
Yes, but if the class is designed for unique_ptr style usage...
Anyway, a destructor is the "END" for the constructor "BEGIN".
Together they form a scope. The children of the scope ought to
live until the "END". The background for constructor/destructor
is that they match a closure. Simula had the INNER keyword so
that you could write:
CLASS Transaction BEGIN
...open...
INNER
...close...
END
Then specialize it by prefix style subclassing:
Transaction BEGIN
...do stuff executed in the inner clause...
END
C++ offer similar semantics with constructor/destructor RAII...
Some languages keep track of parent-child relationships, you can
do it in the typing even. Nevertheless, children ought to be
alive when the parent dies... If the language cannot provide
this, then provide another mechanism such as "finalize" or just
disallow GC allocating destructor based classes.
Mish-mashing established programming concepts is Not a Good Idea.
:)
More information about the Digitalmars-d
mailing list