Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rutgers!ucla-cs!zen!ucbvax!UDEL.EDU!Chester From: Chester@UDEL.EDU Newsgroups: comp.ai.digest Subject: Re: Garbage Collection Suppression Message-ID: <8707202143.aa23792@Dewey.UDEL.EDU> Date: Mon, 20-Jul-87 21:43:00 EDT Article-I.D.: Dewey.8707202143.aa23792 Posted: Mon Jul 20 21:43:00 1987 Date-Received: Fri, 24-Jul-87 00:52:12 EDT Sender: daemon@ucbvax.BERKELEY.EDU Distribution: world Organization: The ARPA Internet Lines: 20 Approved: ailist@stripe.sri.com The direct way to avoid garbage collection in lisp is to define your own `cons' function that prefers to get cell pairs from an `available list', calling the regular `cons' only when the `available list' is empty. A `reclaim' function that puts cell pairs on the `available list' (using `rplacd') will be needed also. See any book on data structures. The technique can be used for cell pairs and gensym atoms, if needed, but in my experience, not with strings or numbers. String manipulations can usually be avoided, but a program that crunches a lot of numbers cannot avoid consuming memory and eventually triggering garbage collection (at least in VAX lisp). I wish there were some way for a user to reclaim numbers so that they could be reused as cell pairs can. If so, I could write all my lisp programs so that they don't need to garbage collect. It would also be nice to have a built-in `reclaim' function that would work in conjunction with the built-in `cons'; it would be dangerous for novices, but handy for the experienced. By the way, recursion in itself doesn't cause garbage collection; VAX lisp is smart enough to reclaim the memory used for the function stack automatically. Daniel Chester chester@dewey.udel.edu