Path: utzoo!mnetor!tmsoft!torsqnt!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!mcsun!ukc!cam-cl!scc From: scc@cl.cam.ac.uk (Stephen Crawley) Newsgroups: comp.sw.components Subject: Re: Re: Real-time Garbage Collection Message-ID: <896@scaup.cl.cam.ac.uk> Date: 20 Sep 89 00:23:22 GMT References: <6497@hubcap.clemson.edu> Sender: news@cl.cam.ac.uk Organization: U of Cambridge Comp Lab, UK Lines: 27 Bill Wolf (?) writes: >>> It's safe to [reclaim a dynamicly allocated ADT]: >>> 1) When the variable goes out of scope >>> 2) When the programmer specifies that it's to be destroyed sooner. Anton Rang replies: >> If there's any explicit pointer manipulation, these conditions >> aren't sufficient, because an object can be pointed to in more than >> one place. In addition: 1) doesn't work if a given scope doesn't exit before you've run out of space OR if the value in a variable is passed out of the scope. 2) doesn't work unless your programmer writes perfect code. Bill Wolf replies: > True, but the basic thrust of the position is that the programmer > should generally not use pointers explicitly; rather, the use of > pointers should be made safe via encapsulation within a secure ADT. Anton is absolutely right. It makes no difference whether references to an ADT is implicit or explicit. The ADT cannot know whether or not the application that uses it still holds a reference to a given instance. In all but the simple cases the application must take a hand in the ADT's storage management, either by invoking the ADT's deallocator explicitly or by telling the ADT when to incrementing/decrementing a reference count.