strange work of GC
Andrey Derzhavin via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Feb 7 11:32:34 PST 2015
> Why do you want to use destroy?
The destroy method always calls a dtor of the objects, where I
can destroy some
object's variables in that order that I need, I think. And this
is very good for me, because I have a full control of the
object's destroying stage.
But if I use the GC, I have no garanties that the dtors will be
called, therefore some of my methods will not be called too. In
this case
it would be better to disable automatically garbage collection in
my D app, elsewise once app will be failed (manual destroying
idiom).
On another hand if I use only GC (automatically destroying
idiom), I have to disable "destroy" method and all dtors of the
objects,
so that nobody can call "destroy" method. Otherwise app will be
failed once again.
Two idioms are existing in one app at the same time have more
possiblities for D programmers to make hard errors in their code,
and it is confusing me sometimes.
For example, .Net (C#) have no dtors and "destroy" methods. It is
a very good idiom, because no confusions occur.
More information about the Digitalmars-d-learn
mailing list