About RAII and GC...?
Daniel Keep
daniel.keep.lists at gmail.com
Mon Jul 30 19:28:03 PDT 2007
Jarrett Billingsley wrote:
> "Nick Sabalausky" <a at a.a> wrote in message
> news:f8m0fq$2ogm$1 at digitalmars.com...
>> Maybe I'm misunderstanding things, but if you use RAII wherever
>> appropriate, wouldn't that eliminate the need for garbage collection? Is
>> there something I'm missing here?
>
> Go ahead and program your entire program without persisting any state
> outside the program execution stack. Let us know how it goes ;)
>
> Basically RAII only works for local function variables. If you want the
> lifetime of an object to be controlled by something other than the execution
> time of a function, that's what the GC is for.
>
> Although I wonder how much the GC could be helped by means of a new kind of
> object lifetime control, where the lifetime of one object is controlled by
> the lifetime of another. Collecting the "parent" object would cause the
> "child" object to be collected, and the child couldn't be collectable until
> the parent object was.
Scoped member variables; second half of my old proposal :P
http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=38329
-- Daniel
More information about the Digitalmars-d
mailing list