views:

560

answers:

3
+6  Q: 

Lisp image

Essentially, I would like to know what a Lisp image is? s it a slice of memory containing the Lisp interpreter and one or more programs or what?

+4  A: 

Several language implementations use an 'image' to store ''everything'' that is there in the current context. This image may several abstraction layers of compilation ( i.e. an intermediate parse level, an intermediate byte code, native op codes ). Loading this image will be much faster than compiling all the source files. It's very much like the hibernate feature, at a program level.

For example , if your-lisp-implementation uses a image, than first you ( or the compiler vendor will ) boot strap an image, and save it.

Then you have two options: (1) either load your lisp file everytime you invoke lisp or (2) load all your lisp, and save the image , and use this image

Hope that helps

Vardhan Varma
+2  A: 

In general, it's the storage part of the lisp process (that is, all "lisp" functions and data), but no parts of the underlying lisp binary. On the plus side, this gives a fast start-up, since there's (essentially) no book-keeping to be done on loading the image, everything is just there. On the other hand, it means any open files, sockets and what-have-you are missing, so saving images as some sort of check-pointing will require a bit of implementation to make it work.

Vatine
+11  A: 

The image is usually a file. It is a dump of the memory of a Lisp system. It contains all functions, variable values, symbols, etc. of the the Lisp system. It is a snapshot of a running Lisp.

To create an image, one starts the Lisp, uses it for a while and then one dumps an image (the name of the function to do that depends on the implementation).

Next time one restarts Lisp, one can use the dumped image and gets a state back roughly where one was before. When dumping an image one can also tell the Lisp what it should do when the dumped image is started. That way one can reconnect to servers, open files again, etc.

To start such a Lisp system, one needs a kernel and an image. Sometimes the Lisp can put both into a single file, so that an executable file contains both the kernel (with some runtime functionality) and the image data.

On a Lisp Machine a kind of boot loader (the FEP, Front End Processor) may load the image (called 'world') into memory and then start this image. In this case there is no kernel and all that is running on the computer is this Lisp image, which contains all functionality (interpreter, compiler, memory management, GC, network stack, drivers, ...). Basically it is an OS in a single file.

Some Lisp systems will optimize the memory before dumping an image. They may do a garbage collection, order the objects in memory, etc.

Why would one use images? It saves time to load things and one can give preconfigured Lisp systems with application code and data to users.

Using images in Lisp is very similar to what Smalltalk systems do. Squeak for example also uses an image of Smalltalk code and data and a runtime executable.

For an example see the function save-image of LispWorks.

Rainer Joswig