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

Redefinition of system functions



Problem description:
CLtL allows the redefinition of functions exported from other packages. 
Unexperienced programmers may redefine a system function unintentional 
which may result into an inconsistent state of the system and cause to 
abort.

This happens, for example, if a beginner follows the CL introductory 
book "Essential LISP" by Anderson et.al. page 41 where an exercise asks 
to define a function make-list. After the redefinition of make-list the 
system crashs without returning a message that the function has been 
redefined.

CLtL only says that special forms can not be redefined. But this doesn't 
solve the general problem of redefining system functions.

Solution:
Redefinition of exported functions should stay allowed. However, some 
functions - especially all functions of the package LISP -  should be 
protected from redefinition. In the case a user tries to redefine such a 
function a confirmation should be required.

Protected user functions can be specified in a special list (look-up-
table, value of the variable *protected-functions-from-redefinition*). 
Functions from package LISP are protected per se and have not to be 
added into this list. 
There should be two functions to add and to remove an entry to/from this 
list:
protect-function-from-redefinition name
release-function-for-redefinition name

The only function involved in protecting functions from redefinition 
seems to be defun. Advising (in the sense of Interlisp) protected 
functions, however, should stay allowed. 


Dieter Kolb