[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

The Common Lisp Condition System for KCL

The file  pub/lisp/clcs.tar.Z  (available for anonymous ftp from 
turing.cs.rpi.edu) contains an implementation of the Common Lisp
Condition System for KCL.  It is based on the file  cl/conditions/cond18.lisp
(available for anonymous ftp from arisia.xerox.com), and will work
both with and without CLOS.

To install clcs,
 cd to the directory which is to contain the clcs directory,
 type: zcat clcs.tar.Z | tar xf -
 type: cd clcs
 edit the value of *clcs-root-directory* in sysdef.lsp,
 then run lisp and do:
  (compile-file "sysdef") ; optional
  (load "sysdef")
 and then run lisp again and either do:
  (load "sysdef") ; -- do this sequence if you are going to save lisp
  (save "clcs") ; or any other file name
 or do:
  (load "sysdef") 
  (si:top-level) ; because the old top-level (which is still running)
                 ; does not establish restarts

The KCL functions which are changed by (load-clcs) are all
defined in the file top-patches.lisp:
  si::top-level          ; Add the "Return to top level." ABORT restart.
  si::universal-error-handler ; Use restarts for continuable errors.
  break                  ; Add the "Return from BREAK." CONTINUE restart.
                         ; When si::*break-enable* is nil,
                         ;   do not call si::break-level.
  si::break-level        ; Add the "Return to debug level ~D." ABORT restart.
                         ; Change si::break-level so that it never returns.
                         ; Call show-restarts initially.
                         ; :resume invokes most recent CONTINUE restart.
                         ; Positive integers are used to select other restarts.
  si::terminal-interrupt ; The arguments to cerror were reversed.
  si::break-quit         ; Returns by invoking an ABORT restart.
These changes do not affect error signalling at all.
If an error occurrs between the (first) time that you call (load-clcs) and the 
time you call either (si:top-level) or (save ...), you will be unable to
exit from (si::break-level).  This happens because the old top-level 
(which is still running) does not establish restarts.  

To actually use the Common Lisp Condition System,
the function (conditions::install-clcs-symbols) must be run.
It replaces the definition of si::universal-error-handler
with the definition of conditions::clcs-universal-error-handler,
and replaces the definitions of:
  break error cerror warn check-type assert etypecase ctypecase ecase ccase
with definitions from the CONDITIONS package.

If PCL (or some other CLOS implementation) is loaded after
clcs is loaded, and you want to change clcs to use clos,
just call (load-clcs) again.  (You might need to call 
(compile-clcs) first.)  The CLOS dependencies are restricted to 
the files conditions.lisp and condition-definitions.lisp.
The object files for these two files have different names depending
on whether CLOS is loaded (...-defstruct.o or ...-clos.o).

Still to do:
  The mapping from error-name,error-format-string (the first and 
fifth arguments to si:universal-error-handler) to condition classes
that is defined in the file kcl-cond.lisp is incomplete.  The error
calls made by the kcl files c/error.c, c/eval.c, and c/file.d are
mapped correctly, but other all other calls are mapped to a
condition (conditions::internal-simple-error) that is (often) less 
specific than the correct condition.  
  I think it would be very helpful to add restart loops to 
compile-file and compile, so that the user gets a chance to
retry the operation if it fails.

  Richard Harris