Is there a command to halt the interpreter in Common Lisp?
There is no standard way to exit a CL environment. To find out how to do it in the implementation you're using, read its documentation.
In sbcl, (sb-ext:quit)
will do the trick. For clisp, it's (ext:exit)
. The clisp documentation for the command is at http://clisp.sourceforge.net/impnotes.html#quit
Since most Lisps import a quit function into CL-USER, CL-USER::QUIT is a good guess without knowing the implementation specific package where it is.
(cl-user::quit)
Note the two colons, since QUIT does not need to be exported from the CL-USER package.
As far as I know, this is not covered by the Spec, and you will have to use the implementation-specific solutions, or maybe try and look if someone has already written a trivial-quit lib (or start one on CLiki).
If you only care about interactive use, ,q
in SLIME will always do the right thing. Otherwise, you may use read-time conditionals like this:
(defun my-quit ()
#+sbcl (sb-ext:quit)
#+clisp (ext:exit)
#+ccl (ccl:quit)
#+allegro (excl:exit)) ;; and so on ...
#+
checks, if the following symbol is in *features*
. If not, the following form will be treated as white-space. (There is also #-
for the opposite).