Getting Started
Install Lisp
- Install Lisp using the
sudo apt install sbclcommand - Run SBCL simply by typing
sbcl
(print "Hello Lisp!!")
- Our string is printed twice, because the function
printprints our string on the standard output, but the function also returns a result, which is printed on the REPL. - You can do
(exit)to close the REPL.
Readline Support
- Install the readline wrapper. It is just a utility to help with keybindings and history
sudo apt install rlwrap
# Call the rlwrap library
rlwrap sbcl
- Alternatively you can use the Linedit library (you would need the Quicklisp package manager for that):
- Quicklisp
- Linedit
Ignore the Interactive Debugger
- Inside the debugger prompt we are not in the normal Lisp REPL anymore. You can type zero to choose the "abort" restart, to come back to the default prompt. You can also do Control + D to exit it.
- How to not invoke the Interactive debugger every time you make a mistake, but only show the error message, so that you can carry on:
- Edit your
sbclrcfile in the home directory
- Edit your
;;; Diable the interactive debugger
(defun print-condition-hook (condition hook)
"print this error message (condition) and abort the current operation."
(declare (ignore hook))
(princ condition)
(clear-input)
(abort))
(setf *debugger-hook* #'print-condition-hook)
Implementations
There are several Lisp implementations. There is a lot of history with Common Lisp, and most of them are not relevant anymore. If you don't know what to use, go with SBCL. Another good one is Clozure CCL, which is known to compile itself in a few seconds. LispWorks is proprietary, but it has a free version with limitations. It is a new world by itself, worth exploring because it has good graphical widgets. The GNU CLisp implementation is lagging behind (but it has a really good REPL)