X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Ffdefinition.lisp;h=e4634f8b38e29a717eb4ef0ebf2b3db6a7cf9da7;hb=c3699db2053ff3b5ac6a98d4431c3789496002d8;hp=c78367265cfb37df1109ccbf83cbe2a726aa6cf8;hpb=5ec8d0c1c8b7939818b75118b472fac1af554f9a;p=sbcl.git diff --git a/src/code/fdefinition.lisp b/src/code/fdefinition.lisp index c783672..e4634f8 100644 --- a/src/code/fdefinition.lisp +++ b/src/code/fdefinition.lisp @@ -54,12 +54,7 @@ ;;; CREATE is non-NIL, create a new (unbound) one. (defun fdefinition-object (name create) (declare (values (or fdefn null))) - (unless (legal-fun-name-p name) - (error 'simple-type-error - :datum name - :expected-type '(or symbol list) - :format-control "invalid function name: ~S" - :format-arguments (list name))) + (legal-fun-name-or-type-error name) (let ((fdefn (info :function :definition name))) (if (and (null fdefn) create) (setf (info :function :definition name) (make-fdefn name)) @@ -88,7 +83,7 @@ (type definition)) (:copier nil)) ;; This is definition's encapsulation type. The encapsulated - ;; definition is in the previous encapsulation-info element or + ;; definition is in the previous ENCAPSULATION-INFO element or ;; installed as the global definition of some function name. type ;; the previous, encapsulated definition. This used to be installed @@ -97,8 +92,8 @@ (definition nil :type function)) ;;; Replace the definition of NAME with a function that binds NAME's -;;; arguments a variable named argument-list, binds name's definition -;;; to a variable named basic-definition, and evaluates BODY in that +;;; arguments to a variable named ARG-LIST, binds name's definition +;;; to a variable named BASIC-DEFINITION, and evaluates BODY in that ;;; context. TYPE is whatever you would like to associate with this ;;; encapsulation for identification in case you need multiple ;;; encapsulations of the same name. @@ -117,8 +112,8 @@ ;; an encapsulation that no longer exists. (let ((info (make-encapsulation-info type (fdefn-fun fdefn)))) (setf (fdefn-fun fdefn) - (lambda (&rest argument-list) - (declare (special argument-list)) + (named-lambda encapsulate (&rest arg-list) + (declare (special arg-list)) (let ((basic-definition (encapsulation-info-definition info))) (declare (special basic-definition)) (eval body))))))) @@ -126,6 +121,7 @@ ;;; This is like FIND-IF, except that we do it on a compiled closure's ;;; environment. (defun find-if-in-closure (test fun) + (declare (type function test)) (dotimes (index (1- (get-closure-length fun))) (let ((elt (%closure-index-ref fun index))) (when (funcall test elt) @@ -139,7 +135,7 @@ ;;; When removing an encapsulation, we must remember that ;;; encapsulating definitions close over a reference to the -;;; encapsulation-info that describes the encapsulating definition. +;;; ENCAPSULATION-INFO that describes the encapsulating definition. ;;; When you find an info with the target type, the previous info in ;;; the chain has the ensulating definition of that type. We take the ;;; encapsulated definition from the info with the target type, and we @@ -224,15 +220,15 @@ This is SETF'able." (let ((fun (%coerce-name-to-fun name))) (loop - (let ((encap-info (encapsulation-info fun))) - (if encap-info - (setf fun (encapsulation-info-definition encap-info)) - (return fun)))))) + (let ((encap-info (encapsulation-info fun))) + (if encap-info + (setf fun (encapsulation-info-definition encap-info)) + (return fun)))))) (defvar *setf-fdefinition-hook* nil #!+sb-doc - "This holds functions that (SETF FDEFINITION) invokes before storing the - new value. These functions take the function name and the new value.") + "A list of functions that (SETF FDEFINITION) invokes before storing the + new value. The functions take the function name and the new value.") (defun %set-fdefinition (name new-value) #!+sb-doc @@ -243,6 +239,7 @@ ;; top level forms in the kernel core startup. (when (boundp '*setf-fdefinition-hook*) (dolist (f *setf-fdefinition-hook*) + (declare (type function f)) (funcall f name new-value))) (let ((encap-info (encapsulation-info (fdefn-fun fdefn)))) @@ -273,4 +270,5 @@ (let ((fdefn (fdefinition-object name nil))) (when fdefn (fdefn-makunbound fdefn))) + (sb!kernel:undefine-fun-name name) name)