Finalizing GC

Leandro Motta Barros lmb at stackedboxes.org
Mon Apr 1 10:52:05 PDT 2013


On Mon, Apr 1, 2013 at 1:45 PM, H. S. Teoh <hsteoh at quickfur.ath.cx> wrote:
> On Mon, Apr 01, 2013 at 01:07:56AM -0700, Jonathan M Davis wrote:
>> On Sunday, March 31, 2013 20:51:52 H. S. Teoh wrote:
>> > On Sun, Mar 31, 2013 at 06:29:21PM -0700, Jonathan M Davis wrote:
>> > [...]
> Seems to me like dtors should be removed from the language. Well, except
> struct dtors, which I believe do work when the struct goes out of scope?

I believe that destructors are also guaranteed to be called for "scope
classes" and "scope objects".

Anyway, I had the same feeling when I first learned that destructors
are not guaranteed to be called. I am still trying to find idioms to
do proper resource management in D when trying "class-heavy" designs.
BTW, I think that C# behaves similarly, so I guess these idioms do
exist.

("scope" statements are great when they can be used, and RefCounted
works for other cases, but they don't seem to solve all my problems.)

LMB


More information about the Digitalmars-d-learn mailing list