Subject: Re: How to programmatically exit?
From: (Rob Warnock)
Date: Tue, 28 Oct 2008 05:47:57 -0500
Newsgroups: comp.lang.lisp
Message-ID: <>
Willem Broekema  <> wrote:
| (Rob Warnock) wrote:
| >  (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)
| >     ...
| >     #-(or allegro clisp cmu cormanlisp gcl lispworks lucid sbcl
| >        kcl scl openmcl mcl abcl ecl)
| >     (error 'not-implemented :proc (list 'quit code)))
| You could even skip the #-(...) in this case. :)

Yes, that's true. But exiting the entire program is a very special
case and I didn't want to encourage sloppiness in the general case
where you *do* want to return a value, e.g., this function from the
"archive_0.7.0" package:

    ;;; stat field accessors
    (defun stat-mode (stat)
      #+sbcl (sb-posix::stat-mode stat)
      #+lispworks (file-stat-mode stat)
      #+clisp (posix:convert-mode (posix:file-stat-mode state))
      #+cmucl (mode stat)
      #-(or sbcl lispworks clisp cmucl) (error "Not implemented"))

So it's probably best to always include the #-(OR ...) list,
just to avoid mistakes by accident.

Although, now that you mention it, there *is* one other special case
that I can think of where the #-(OR ...) is unnecessary and, in fact,
unwanted, and that's where you're going to return a default value if
the implementation-specific value is NIL, e.g.:

    ;;; This version morphed very slightly from
    ;;; <>
    (defun getenv (name &optional default)
       #+cmu (cdr (assoc name ext:*environment-list* :test #'string=))
       #+allegro (sys:getenv name)
       #+clisp (ext:getenv name)
       #+ecl (si:getenv name)
       #+sbcl (sb-unix::posix-getenv name)
       #+lispworks (lispworks:environment-variable name)


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