I'm interested to know how is implemented the memory in the Lisp abstract
machine and how the garbage collector works. Could someone explain me this?
thanx
"massimo micheloni" <······@aruba.it> writes:
> I'm interested to know how is implemented the memory in the Lisp
> abstract machine and how the garbage collector works. Could someone
> explain me this?
This is not something that permits a straight answer; there are a lot
of Lisp implementations out there, and:
a) They don't necessarily have a conscious formalization of an
"abstract machine."
b) They may use quite different abstractions. There are systems that
generate bytecode (CLISP and CMUCL come to mind) for an
implementation-specific virtual machine; others generate machine
language code for a _concrete_ machine; still others generate C code.
c) Similarly, there are many garbage collectors out there of varying
operational qualities.
--
(concatenate 'string "aa454" ·@freenet.carleton.ca")
http://vip.hyperusa.com/~cbbrowne/lisp.html
As of next month, MACLISP "/" will be flushed in favor of "\".
Please update the WORLD.
massimo micheloni wrote:
>
> memory, garbage collector?
Lisp memory can be thought of as a linked list of "cons" cells.
In an abstract Lisp machine there is a contents list that has
pointers to every object, and there is also an list of the
empty cons cells. Garbage collection marks every cell in the
contents list that is referenced by another cell, then all the
unmarked cells are collected and added to the empty list.
Garbage collection runs when the system asks for more cells
than are available in the empty list, then processing stops
and waits for garbage collection to provide more cells.
This is how it was implemented in P-Lisp, a Pascal version
of Lisp that I used ages ago. Modern Lisp machines (compilers
and interpreters) are far more sophisticated, but basically
the process is the same; memory cells are in linked list
and unreferenced cells (garbage) are collected for reuse.
Thanks,
Jeff Sandys
massimo micheloni <······@aruba.it> wrote in message
·················@fe1.cs.interbusiness.it...
> I'm interested to know how is implemented the memory in the Lisp abstract
> machine and how the garbage collector works. Could someone explain me
this?
> thanx
>
At my website, http://freespace.virgin.net/andrew.bisson/ajblisp.htm you
will
find a simple lisp interpreter written in C styled C++. It is reasonably
well
commented and it works. It uses one of the simplest efficient garbage
collectors; a double-space mark and sweep algorithm. If you can
understand how this works then the more complex systems of garbage
collection are easy to understand. I can also answer any questions that
you may have on this implementation.
HTH
Andy