Non-REPL work flow
- Edit your file
- Compile the file using
compile-file
; fix errors and warnings; repeat.
- Load the file using
load
; evaluate the form you want; repeat
Example
$ cat > f.lisp <<EOF
(defun f (x) (if (zerop x) 1 (* (f (1- x)) x)))
EOF
$ clisp -q -norc -c f.lisp
;; Compiling file /home/sds/f.lisp ...
;; Wrote file /home/sds/f.fas
0 errors, 0 warnings
$ clisp -q -norc -i f.fas -x '(f 10)'
;; Loading file f.fas ...
;; Loaded file f.fas
3628800
$
The Right Way
Use an IDE, e.g., Emacs with SLIME.
This way, you edit the code in an editor which supports auto-indent and shows you help for each standard symbol.
You compile and test the functions as soon as you write them, giving you a very short development cycle. Under the hood this is accomplished by the IDE interacting with the REPL (this answers your last question).
What is REPL?
Read-Eval-Print loop is a faster, more versatile version of the Edit-Compile-Run loop.
Instead of operating in terms of whole programs (which can be slow to compile and whose execution can be tedious to navigate to the specific location being tested), you operate in terms of a specific function you work on.
E.g., in gdb
, you can execute a function with print my_func(123)
, but if you change my_func
, you have to recompile the file and relink the whole executable, and then reload it into gdb
, and then restart the process.
With Lisp-style REPL, all you need to do is re-eval
the (defun my-func ...)
and you can do (my-func 123)
at the prompt.
compile-file
andload
For documentation: see lispworks.com/documentation/HyperSpec/Front/Contents.htm – Bencher