diff --git a/code/fdefinition.lisp b/code/fdefinition.lisp index a1815eae52f0d6a56531b443697b837cfbb88818..3b441560adbfd8c8ace37bd4d1c593ea510c0fb1 100644 --- a/code/fdefinition.lisp +++ b/code/fdefinition.lisp @@ -5,7 +5,7 @@ ;;; Carnegie Mellon University, and has been placed in the public domain. ;;; (ext:file-comment - "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/fdefinition.lisp,v 1.24 2003/05/23 13:34:05 gerd Exp $") + "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/fdefinition.lisp,v 1.25 2003/05/24 10:47:35 gerd Exp $") ;;; ;;; ********************************************************************** ;;; @@ -196,11 +196,11 @@ ;;;; FDEFINITION. -(defun fdefinition (name) - "Return name's global function definition taking care to regard any - encapsulations and to return the innermost encapsulated definition. - This is SETF'able." - (let* ((fdefn (fdefn-or-lose name)) +(defun fdefinition (function-name) + "Return FUNCTION-NAME's global function definition. + If FUNCTION-NAME is fwrapped, return the primary function definition + stored in the innermost fwrapper." + (let* ((fdefn (fdefn-or-lose function-name)) (last (fwrappers:last-fwrapper fdefn))) (if last (fwrappers:fwrapper-next last) @@ -210,13 +210,15 @@ "This holds functions that (SETF FDEFINITION) invokes before storing the new value. These functions take the function name and the new value.") -(defun %set-fdefinition (name new-value) - "Set NAME's global function definition to NEW-VALUE." +(defun %set-fdefinition (function-name new-value) + "Set FUNCTION-NAME's global function definition to NEW-VALUE. + If FUNCTION-NAME is fwrapped, set the primary function stored + in the innermost fwrapper." (declare (type function new-value) (optimize (safety 1))) - (let ((fdefn (fdefinition-object name t))) + (let ((fdefn (fdefinition-object function-name t))) (when (boundp '*setf-fdefinition-hook*) (dolist (f *setf-fdefinition-hook*) - (funcall f name new-value))) + (funcall f function-name new-value))) (let ((last (fwrappers:last-fwrapper fdefn))) (if last (setf (fwrappers:fwrapper-next last) new-value) diff --git a/docs/cmu-user/extensions.tex b/docs/cmu-user/extensions.tex index 387ae46e64108990f32193eb87caf2e6326ae27d..1755a178bd902cdfb3f0c0dbaa88f830548e9241 100644 --- a/docs/cmu-user/extensions.tex +++ b/docs/cmu-user/extensions.tex @@ -2248,6 +2248,13 @@ Example: Fwrappers are used in the implementation of \code{trace} and \code{profile}. +Please note that \code{fdefinition} always returns the primary +definition of a function; if a function is fwrapped, +\code{fdefinition} returns the primary function stored in the +innermost fwrapper object. Likewise, if a function is fwrapped, +\code{(setf fdefinition)} will set the primary function in the +innermost fwrapper. + \begin{defmac}{fwrappers:}{define-fwrapper}{name lambda-list \ampbody body} This macro is like \code{defun}, but defines a function named \var{name} that can be used as an fwrapper definition.