[gclist] Re: gclist-digest V1 #41

Jerry Leichter leichter@smarts.com
Fri, 19 Apr 1996 15:30:22 -0400


| "
| | To put gc in a *language definition*, one would need a model of storage
| | usage that is far more detailed than is typical.
| 
| What this mainly proves it the poverty of "typical" language descriptions.
| "
| 
| I think there are good reasons both for and against including such things
| in language descriptions.  Modelling storage use in enough detail to be
| useful is likely to constrain the optimizer significantly.  (SML of NJ and
| Andrew Appel's book actually do this, for good reason.  But I think Andrew
| also would agree that this is not free.)
|
| If you don't include a detailed model of storage usage (and I think
| a C or C++ standard shouldn't),  that precludes a completely formal
| requirement for GC....

I think we're losing track of the point here.  Many languages, and more exactly 
many languages in specific classes of environments, don't "need" garbage 
collection.  Others - in particular, those which allow heap data to be 
allocated, whether by explicit "new" calls or implicitly through something like 
LISP CONS but don't have an explicit "free" call - need GC to make much sense.  
In neither case does a formal requirement add much.  In the former case, we 
would never expect to have GC available, and the bias in the language design and 
intended and actual usage leaves the programmer to control storage re-use.  In 
the latter case, a formal requirement for GC is perhaps about as necessary as a 
formal requirment that a C compiler free stack frames on return from procedures. 
(Then again, I think the Java specs explictly say that GC will be provided, 
exactly because so much of the intended Java audience is C and C++ programmers 
to whom the idea is new.)

The interesting cases are in the middle.  Modula-3 has both GC'ed and non-GC'ed 
memory, and you can, in fact, explicitly dispose of GC'ed memory (though that's 
essentially a no-op).  If the Modula-3 spec never mentioned GC, it would have a 
hard time explaining what the difference between the two classes of memory 
really is!

If, as the designer of the language, you intend that the language be used in a 
style that requires garbage collection, you should specify that GC will be 
provided by conforming implementations.  Why *not* say what you mean?

I'll also point out again that if you want to provide things like destructors 
for implictly freed objects, or 
weak references, there's no way you can say anything sensible about them without 
defining, at least in general, mainly informal terms, a storage and GC model.
							-- Jerry