Here's another hair for you to split: ______________________________
Talking about one of the most fundamental aspects of C++ is not
splitting hairs. Just because you don't know C++ doesn't mean
that the language will change to suit your misconceptions.
Anyone who is not involved with splitting hairs, for a living,
would clearly understand that I was referring to the fact that
"delete" does both: destruction and memory reclamation. It's
one shot, in C++.
Anyone who knows the C++ object model knows that the delete
operator (like the new operator) does two very distinct things.
Involving different functions. In the absense of garbage
collection, it was often convenient to associate them---thus, a
single operator. But they are, and always have been two
distinct operations. The distinction is fundamental to the C++
object model.
Damn right! There's no such thing as "delete", in C++, which
handles both object destruction and memory release. There's a
"foo", that does the first part, and "bar", that does the
second one. My mistake.
Yup. Your mistake. I'd suggest you read a little about how C++
works. You might start with the definition of the delete
operator, §5.3.5. And sections §3.7 and §3.8, of course: the
first treats storage duration, and the second object lifetime.
(The standard considers them different enough to treat them in
two separate sections.)
Why do you keep repeating this, that object destruction and
memory release are two completely separate processes in C++,
when it's been explained to you that it's completely false.
Nothing has been explained to me. The standard says that they
are two distinct operations. You've not said anything which
would make me doubt the standard.
Maybe on your planet C++ works this way, but not on this one.
Try reading the standard sometime. Or even learning some of the
more basics of the language.
And how do you expect to arrive to such a conclusion? A random
number generator? Yippee! It evaluated to 0.53 -- must mean
that no further pointers remain, and we can reclaim the
object.
Are you being intentionally stupid, or have you really never
heard of assertions? Or programming by contract? Or writing
robust code?
Not on my planet, where it works every time it's used
properly, and garbage collection is an ugly hack for the lazy
asses who can't be bothered to track and manage their objects,
properly.
That planet must not be in the known universe, because it
violates all proven rules of logic. Shared_ptr doesn't work in
all cases; you need all sorts of hacks to make it work (break
cycles, etc.). In the absense of garbage collection, it's often
better than nothing, but it's certainly not as good as the real
thing.
Repeating the same absurdity a given number of times won't
suddenly turn it into sense.
The difference is that my "absurdity" is based on the C++
standard, the way C++ really works, the proposal to add garbage
collection to C++, and actual implementations of garbage
collection. What's yours based on, except your imagination and
your misunderstanding of C++.
The whole and the only purpose of garbage collection is to
clean up after yourself, when you can't be bothered to do it
properly.
The whole and only purpose of garbage collection is to manage
memory. At least, that's what the authors of the proposal to
add it to C++ say, and that's what the authors of the garbage
collector I use say.
Inventing something else and calling it garbage collection may
satify some fancy of yours, but it isn't very intellectually
honest.
That's the sole and the only purpose for it, because if you do
know what you're doing, you simply don't need garbage
collection. Not in C++, at least.
Do you actually read the posts you respond to? I've stated
several times: garbage collection reduces the amount of work you
need to do. That's all. It won't turn an incompetent
programmer miraculously into a competent one. If you know what
you are doing, you don't need garbage collection. Nor
templates. Nor classes. They just mean that you need less time
and effort to acheive the same ends.
Brilliant! "I'm too stupid to know how to track my objects'
lifetime, so I'll just use garbage collection in some twisted
way, in order to save my lazy ass."
I suppose you've never seen a program with an error. Neither in
the code you write, or that of your collegues. The fact remains
that good code makes extensive use of assertions, to detect
error conditions.
I call "knowing how to do your job, WRT class design an
implementation" more robust than using an ugly, revolting hack
like C++-based garbage collection.
It sounds more to me that you don't know what "knowing how to do
your job" involves, at least if your job is in software
engineering.
There's no such thing as garbage collection in "basic C++
object mode." The formal language just does not define
anything of that sort. Feel free to cite the part of ISO/IEC
14882:2003 that defines garbage collection for "basic C++
object mode". Whatever that is.
It would help, again, if you'd read what you are replying to.
The C++ standard definitly separates memory allocation from
object lifetime. Two very distinct things. And the role of
garbage collection in C++ is the handle memory allocation, not
object lifetime. Regardless of what you claim.
Garbage collection for C++ always involves some third-party
slapdash code that seems to compete with Boost for the gold
prize in the C++ obfuscation context.
Have you actually used it? Have you read the proposals for it?
Do you actually know the least thing about what you are saying?
Actually, reflecting on the last 10+ years of looking at C++
code in financial apps -- that are responsible for moving huge
volumes of business critical market data -- I do not recall
even a single instance of anyone using anything can even be
remotely described, in some nightmarish context, as "garbage
collection." Sorry, but established facts disagree with your
theories.
Really. I've worked on banking applications which used garbage
collection.
"C++ garbage collection" is the very essence of "unnecessary work".
Writing a garbage collector for C++ isn't trivial, but as others
have already done it.
You better sit down, because the following may come as a shock to you.
Here's a newsflash: there's plenty of "robust software" going
around that does not involve garbage collection. Well, how'd
that happen, huh?
People spent more time implementing it than was necessary.
Can't you read? It's a tool. There's also plenty of "robust
software" going around that's written in assembler. When I have
a choice, however, I use a high level language---I know how to
write robust software in assembler, but it's a lot more work.
It's practically the definition of an engineer.
If I ever meet some candidate who walks off the street, and
starts spouting something or other about the wonders of
garbage collection in C++,
Strawman. Who's talking about the wonders of anything. We're
just talking about a tool to improve programmer productivity and
program reliability.
I'll politely thank him, strike his name off the list, and
move on to the next one. Nobody who knows what he's doing, in
C++, has any use for this garbage collection nonsense.
Except, perhaps, the professionals who are using it. (FWIW: one
of the major proponents of the proposal in C++ is Bjarne
Stroustrup. Are you saying that he doesn't know what he's
doing?)
Anyway, I give up. You've shown that you don't really know C++,
nor anything about software engineering. Worse, you've shown
that you're unwilling to learn. I just hope I never have to use
anything you've written.