From e11463161d2e8da12921461a8defe62a3d6c5de6 Mon Sep 17 00:00:00 2001 From: gerd <gerd> Date: Sat, 24 May 2003 10:47:35 +0000 Subject: [PATCH] * src/docs/cmu-user/extensions.tex (section{Function Wrappers}): Add some text wrt fdefinition/(setf fdefinition). * src/code/fdefinition.lisp (fdefinition, %set-fdefinition): Improve doc strings. --- code/fdefinition.lisp | 22 ++++++++++++---------- docs/cmu-user/extensions.tex | 7 +++++++ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/code/fdefinition.lisp b/code/fdefinition.lisp index a1815eae5..3b441560a 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 387ae46e6..1755a178b 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. -- GitLab