Subject: Re: How to programmatically exit?
From: (Rob Warnock)
Date: Sat, 25 Oct 2008 20:09:13 -0500
Newsgroups: comp.lang.lisp
Message-ID: <>
Waldek Hebisch  <> wrote:
| Russell Wallace <> wrote:
| > From within a portable Lisp program, how do you exit cleanly...
| > exit(0) in C? I can't find anything in the hyperspec or Google...
| > maybe I'm overlooking something obvious.
| Such functionality is missing from ANSI CL, so any solution will
| be more or less unportable.  The following is a reasonable
| approximation for free Lisp implementations...
| ;;; How to exit Lisp process
| #+:gcl
| (defun quit() (lisp::quit))
| #+:sbcl
| (defun quit()
|     (sb-ext::quit))

And so on...

A style that's less visually confusing (IMHO) puts all of the
feature tests[1] inside a single copy of the function in question,
documenting the common API in a single place. The following is
a merge of the set from <>, the
set from Maxima, and yours:

    (defun quit (&optional code)
      ;; This group from "clocc-port/ext.lisp"
      #+allegro (excl:exit code)
      #+clisp (#+lisp=cl ext:quit #-lisp=cl lisp:quit code)
      #+cmu (ext:quit code)
      #+cormanlisp (win32:exitprocess code)
      #+gcl (lisp:bye code)			; XXX Or is it LISP::QUIT?
      #+lispworks (lw:quit :status code)
      #+lucid (lcl:quit code)
      #+sbcl (sb-ext:quit
	      :unix-code (typecase code (number code) (null 0) (t 1)))
      ;; This group from Maxima
      #+kcl (lisp::bye)				; XXX Does this take an arg?
      #+scl (ext:quit code)			; XXX Pretty sure this *does*.
      #+(or openmcl mcl) (ccl::quit)
      #+abcl (cl-user::quit)
      #+ecl (si:quit)
      ;; This group from <>
      #+poplog (poplog::bye)			; XXX Does this take an arg?
      #-(or allegro clisp cmu cormanlisp gcl lispworks lucid sbcl
	    kcl scl openmcl mcl abcl ecl)
      (error 'not-implemented :proc (list 'quit code)))


p.s. Note that you never need an explicit keyword package marker on
a symbol in a feature test, e.g. #+:FOO, since feature expressions
are read *in* the KEYWORD package, see CLHS " Sharpsign Plus",
" Sharpsign Minus", & " Feature Expressions".

Rob Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607