Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cwjcc!tut.cis.ohio-state.edu!pt.cs.cmu.edu!wb1.cs.cmu.edu!ram
From: ram@wb1.cs.cmu.edu (Rob MacLachlan)
Newsgroups: comp.sw.components
Subject: Re:  Re: Garbage Collection & ADTs
Message-ID: <6287@pt.cs.cmu.edu>
Date: 26 Sep 89 17:38:08 GMT
References: <900@scaup.cl.cam.ac.uk> <6530@hubcap.clemson.edu> <909@scaup.cl.cam.ac.uk> <62342@tut.cis.ohio-state.edu> <599@hsi86.hsi.UUCP>
Organization: Carnegie-Mellon University, CS/RI
Lines: 36


From: wright@hsi.UUCP (Gary Wright)
Subject: Re:  Re: Garbage Collection & ADTs
Date: 25 Sep 89 15:14:32 GMT
[...]
>What we need to determine is if a language that supports GC allows programs
>to be expressed in a form that is "better" than a language without GC.

You are right on target here.  It is silly to claim that "problem X can only
be solved in language Y"; the interesting question is whether language Y
admits a solution to X that is:
 -- More efficient
 -- More robust
 -- More easily (quickly) written
 -- Easier to understand (to maintain)
 -- Aids code reuse [token concession to the nominal subject]
 -- More likely to be correct, etc.

>Perhaps a sufficiently smart compiler for a language that supports GC can
>figure out when GC can be avoided?  That is to say, the compiler can notice
>when the last reference to an object will be lost and can explicity
>"dispose" of the object.

For a long time Lisp compilers have attempted to recognize when some objects
can be allocated according to a stack discipline, rather than being heap
allocated.  This has been done primarily with numbers, lists and closures.
The ML compiler has an interesting optimization along these lines: if all
references to an allocated object can be identified as being in the same
function, then the allocation can be replaced with a collection of temporary
varaibles.

Of course, both of these allocation optimizations are aimed at eliminating
cons-and-throw-away behavior within a single function.  Programmers used to
thinking of storage allocation as expensive would never write such code.

 Rob