This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: Of Bounties and Mercenaries
- From: "Stephan T. Lavavej" <stl at caltech dot edu>
- To: "GCC" <gcc at gcc dot gnu dot org>
- Date: Tue, 6 Apr 2004 01:27:27 -0700
- Subject: RE: Of Bounties and Mercenaries
- Reply-to: <stl at caltech dot edu>
[Alexandre Oliva]
> It doesn't take care of cycles, though, and they're quite
> pervasive in GCC.
Cycles are the standard objection to my argument.
It also completely misses the point. I advocate using shared_ptr (a
reference counted pointer) to hold noncopyable resource managers - that
doesn't introduce cycles.
If you have a data structure which has cycles, then you should encapsulate
it. For example, std::list is a doubly linked list and hence has cycles of
pointers inside of it. But the user of std::list doesn't have to know or
care about that.
Manual memory management is a reasonable thing to do, as long as it stays
confined to the constructor, destructor, and methods of a single class that
needs to do something exotic. (Of course, the same class can use vectors
and whatnot to do mundane things.)
Stephan T. Lavavej
http://nuwen.net