Re: SGCL - Garbage Collector for C++
On 1 mar, 04:55, Sam <s...@email-scan.com> wrote:
Ian Collins writes:
Sam wrote:
James Kanze writes:
On Mar 1, 12:24 am, Sam <s...@email-scan.com> wrote:
Richard Herring writes:
In message <cone.1204246382.29097.21741....@commodore.email-scan.co=
m>,
Sam <s...@email-scan.com> writes
Let me know when you figure out why, in Java, you have to
throw all these try/catch blocks around, every time you need
to deal with files or sockets,
Because Java doesn't have local objects or destructors. Which
Java most certainly has destructors. See
java.lang.Object.finalize().
But that's not an automatic destructor in the C++ sense, is it?
It has nothing to do with a destructor in the C++ sense, and
serves a completely different role.
It is a destructor in the C++ sense as in "gets invoked before
the object's memory is released".
That's not what a destructor is in C++ (and not necessarily
true---typically, it's not true for local variables, nor for
static objects, nor for member variables, for example). A
destructor in C++ is a function which is called at a specific
time, and "deconstructs" an object into raw memory.
If the destructor is called as part of a delete expression, then
operator delete() will be called immediately afterwards, which
may or may not immediately free the memory. (Typically, it will
immediately free the memory, except in some cases where the
delete is called in a different thread than the corresponding
new.)
That's precisely the point I am making.
The problem is that the point you're making is simply false.
Garbage collection's only benefit is to clean up your objects
when you can't keep track of their lifetime, and must rely on
the garbage collector to destroy the objects when they no
longer have any strong references.
That's the first time I've heard that. No one arguing in favor
of garbage collection has presented such an argument.
Rather than inventing idiocies, and then proving them false, you
should try addressing what people are really saying.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34