About RAII and GC...?

Nick Sabalausky a at a.a
Mon Jul 30 22:56:37 PDT 2007


"Jarrett Billingsley" <kb3ctd2 at yahoo.com> wrote in message 
news:f8m50f$2soh$1 at digitalmars.com...
> "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.
>

Ahh, I see.





More information about the Digitalmars-d mailing list