From: Emil Molina
Subject: Lisp save/load cycle
Date: 
Message-ID: <PSUs6.40086$Xx3.231101@news1.eburwd1.vic.optushome.com.au>
I've put off asking this question for a while but I have not come accross a
good answer anywhere so here goes.

How do I load and save programs in a Lisp environment?

Supposing that I am using something like CLISP and EMACS, if I type in a
function, how do I then write it to disk without creating a new binary
'image'?  How do I then load it?  I am sure this is a case of RTFM but
cannot find it anywhere.

Thanks in advance for help on  a silly question.
From: Kent M Pitman
Subject: Re: Lisp save/load cycle
Date: 
Message-ID: <sfw7l1njvj1.fsf@world.std.com>
"Emil Molina" <·····@optushome.com.au> writes:

> I've put off asking this question for a while but I have not come accross a
> good answer anywhere so here goes.
> 
> How do I load and save programs in a Lisp environment?

If what you mean is "save an executable binary image file like a .exe file",
it's implementation dependent whether you can do this at all, and if you
can do it how you do it.

> Supposing that I am using something like CLISP and EMACS, if I type in a
> function, how do I then write it to disk without creating a new binary
> 'image'?

If you're writing code in Emacs, you should be writing lisp source code
files.  Usually these have .lisp extensions (though some implementations
use .lsp or .l or something like that instead or in addition).  

You can load a lisp source file by using (load "...filename...").
You should not need to "save" such a file, since it was already on disk.
You ordinarily should not edit it in the Lisp image other than through
an editor, which will again save the .lisp source file out.  If you happen
to type a defun at Lisp, you may or may not be able to recover the defun
later, depending on the implementation, but you should not in general 
depend on it.  Rather, you should type definitions you care about saving
(as opposed to trivial ones you use for testing) into a file and then load
the file, so that the file remains for loading in other images on another
day.

> How do I then load it?

Use the function LOAD.

Note, btw, that loading a source file will usually run the code interpreted.
(Some implementations, such as MCL, always compile code, and this is not as
much of an issue, though it will still probably be faster to load if the
code is pre-compiled.)  You can compile a .lisp file using COMPILE-FILE.
This will produce a file with an implementation-dependent extension, such as
.bin or .fasl or something like that.  (Incidentally, "fasl" is a traditional
name going way back and stands for "fast loading".)

> I am sure this is a case of RTFM but
> cannot find it anywhere.

I'm not specifically familiar with CLISP so can't give more than this generic
help above.  Hope it's enough.
 
> Thanks in advance for help on  a silly question.

The question isn't silly.  But really, you should find and read the manual.
Failing a specific manual for CLISP, read the Common Lisp HyperSpec, which
is a webbed version of the standard.  It has the answer to many of these
questions in it.

  http://www.xanalys.com/software_tools/reference/HyperSpec/

You can even download a copy to your own machine for faster reference.
It's about 16MB, if I recall correctly, though the actual size might vary
depending on issues relating to your file system's cluster size.

You can find the answer to other common questions at the ALU web site.
 http://www.alu.org/