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

Undoing global side-effects



I went through the Common Lisp manual looking for functions which have
global side-effects and came up with the following list, along with
suggested functions for removing those side effects:


PROCLAIM SPECIAL
DEFVAR
DEFPARAMETER
  These should all be undoable by MAKUNBOUND and an UNSPECIAL
proclamation.  UNSPECIAL should be restricted to use in PROCLAIM and not
allowed in DECLARE.  This will prevent a major incompatible change in
declaration processing.

DEFCONSTANT
  DELETE-CONSTANT should make a symbol unbound, unspecial and
inconstant (yes, it's a real English word).

DEFUN
DEFMACRO
SETF of SYMBOL-FUNCTION
SETF of MACRO-FUNCTION
  These are undone by FMAKUNBOUND.  In some implementations, DEFUN and
DEFMACRO record information other than the function definition.  Since
this is outside the scope of Common Lisp, the language standard need not
include a way to undo it.

DEFSETF
DEFINE-SETF-METHOD
  These are undone by the DELETE-SETF-METHOD function previously
described.

DEFTYPE
  The DELETE-TYPE function should undo this.  It should signal an error
if any other type is a subtype of the specified type.  It "is an error"
to DELETE-TYPE any of the built-in Common Lisp types.

DEFSTRUCT
  There ought to be a DELETE-DEFSTRUCT function which undoes all the
effects of the DEFSTRUCT, by removing all function definitions
(including compiler database entries for inline compilation), removing
any type database entry, removing the :PRINT-FUNCTION entry, and
removing any information from DEFSTRUCT's own database (that which
allows a name to be used in the :INCLUDE option).  It should signal an
error if any other structure type has :INCLUDEd the given type (unless
that structure type has also been deleted).

MAKE-PACKAGE
  This is undone by the DELETE-PACKAGE function previously described.

SHADOW
  Document the fact that SHADOW can be undone by UNINTERN, causing any
otherwise inherited symbol to become accessible again.

SETF of DOCUMENTATION
SET-MACRO-CHARACTER
SET-DISPATCH-MACRO-CHARACTER
  These should all be undoable by using NIL as the new value.  This must
be documented.


Thus there are five new functions
DELETE-PACKAGE
DELETE-SETF-METHOD
DELETE-CONSTANT
DELETE-TYPE
DELETE-DEFSTRUCT
and one new proclamation, UNSPECIAL.  It doesn't seem to me to be worth
inventing some new SETF-like meta-deletion macro to handle these.  If we
like this naming convention it might a good idea to add the names
DELETE-VALUE and DELETE-FUNCTION as synonyms for MAKUNBOUND and
FMAKUNBOUND, eventually phasing out the latter names.