
on Sat May 02 2009, Achilleas Margaritis <axilmar-AT-gmail.com> wrote:
Therefore, "don't worry about delete; it's taken care of" is not a legitimate programming guideline for C++ with GC. The question is,
******************************************************************** * what /is/ the guideline that explains when I can afford to leak? * ********************************************************************
The best we could come up with in general was, "do everything exactly the same way you were doing it before GC came along," at which point the only benefit of GC seems to be that it may keep a program that leaks from running out of memory as soon as it would have otherwise. That's a pretty marginal benefit, it seems to me.
Yes, I believe that as well: with or without GC, the semantics of a C++ program should not be changed.
Do you realize that "do everything exactly the same way you were doing it before GC came along" means all dynamically-allocated objects must be deleted by explicit code and you can't rely on GC to do it for you? Are you really agreeing with that guideline?
But the benefit is not marginal, as you say. GC solves a lot of problems and, most importantly, increases productivity.
How can it increase productivity if it doesn't change how we write programs? -- Dave Abrahams BoostPro Computing http://www.boostpro.com