All Manuals > LispWorks® User Guide and Reference Manual > 37 The HCL Package

*packages-for-warn-on-redefinition* Variable

Summary

A list specifying packages whose symbols should be checked on attempted definitions.

Package

hcl

Initial Value

(:implementation)

Description

The variable *packages-for-warn-on-redefinition* is a list of package names or the keyword :implementation, specifying packages which are "protected". For "protected" packages, LispWorks checks before defining (using any of the definer macros like cl:defun, cl:defclass and so on) any external symbol of these packages, and takes the action specified by *handle-warn-on-redefinition* (which defaults to signaling an error).

The symbol :implementation in *packages-for-warn-on-redefinition* indicates all of the packages which are part of the LispWorks implementation. That includes all the documented packages, including COMMON-LISP and KEYWORD but excluding some "user" packages like CL-USER and KW-USER, and some packages that are used internally.

For symbol value, setting and rebinding is not checked, but defining using definer macros like cl:defvar and cl:defparameter is checked.

Notes
  1. The checking is useful because it is relatively easy to redefine an external symbol by mistake, and it leads to undefined behavior which is difficult to debug. It is therefore a bad idea to remove :implementation from the list. In situations when this is required, you should do it by rebinding *packages-for-warn-on-redefinition* rather than setting it.
  2. You can protect your packages by adding their package names to this list.
  3. The check is applied for any definition, whether it is actually a redefinition or not. For example, trying to define the symbol cl:stream as a function gives an error (by default), even though cl:stream has only a class definition, and trying to define cl:car as a class also errors even though cl:car has only a function definition.
  4. You can check whether a package is an implementation package by using package-flagged-p with the keyword :implementation.
Compatibility note

:implementation was new in LispWorks 7.0.

In LispWorks 6.1 and earlier versions, the list could contain only package names, and the initial value was a long list of package names.

See also

*handle-warn-on-redefinition*
package-flagged-p
7.7.2.2 Protecting packages


LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:35