Re: Do garbage collected languages need destructors?

From: Robert Klemme (bob.news_at_gmx.net)
Date: 10/31/03


Date: Fri, 31 Oct 2003 17:16:20 +0100


"Dave Harris" <brangdon@cix.co.uk> schrieb im Newsbeitrag
news:memo.20031030200253.656A@brangdon.m...
> bob.news@gmx.net (Robert Klemme) wrote (abridged):
> > Well, at least it has "finally":
>
> Yes. That makes it possible to free resources by hand. However, it
doesn't
> encapsulate the process, which is a major point of a destructor.

Maybe I'm beeing picky here, but the term "destructor" alone does not
imply that it is automatically invoked. In C++ this does only happen for
auto vars. It is by no means guaranteed that the destructor of an
instance allocated on the heap is ever invoked. (Btw, strictly speaking
this isn't even guaranteed for auto vars, but the exceptions to that rule
are very few and typically include fatal behavior. In that case cleanup
usually has to be done by hand: "rm core" on certain systems :-))

Kind regards

    robert