Skip to content
Snippets Groups Projects
Commit e1146316 authored by gerd's avatar gerd
Browse files

* 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.
parent 3e5048ed
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain. ;;; Carnegie Mellon University, and has been placed in the public domain.
;;; ;;;
(ext:file-comment (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 @@ ...@@ -196,11 +196,11 @@
;;;; FDEFINITION. ;;;; FDEFINITION.
(defun fdefinition (name) (defun fdefinition (function-name)
"Return name's global function definition taking care to regard any "Return FUNCTION-NAME's global function definition.
encapsulations and to return the innermost encapsulated definition. If FUNCTION-NAME is fwrapped, return the primary function definition
This is SETF'able." stored in the innermost fwrapper."
(let* ((fdefn (fdefn-or-lose name)) (let* ((fdefn (fdefn-or-lose function-name))
(last (fwrappers:last-fwrapper fdefn))) (last (fwrappers:last-fwrapper fdefn)))
(if last (if last
(fwrappers:fwrapper-next last) (fwrappers:fwrapper-next last)
...@@ -210,13 +210,15 @@ ...@@ -210,13 +210,15 @@
"This holds functions that (SETF FDEFINITION) invokes before storing the "This holds functions that (SETF FDEFINITION) invokes before storing the
new value. These functions take the function name and the new value.") new value. These functions take the function name and the new value.")
(defun %set-fdefinition (name new-value) (defun %set-fdefinition (function-name new-value)
"Set NAME's global function definition to 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))) (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*) (when (boundp '*setf-fdefinition-hook*)
(dolist (f *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))) (let ((last (fwrappers:last-fwrapper fdefn)))
(if last (if last
(setf (fwrappers:fwrapper-next last) new-value) (setf (fwrappers:fwrapper-next last) new-value)
......
...@@ -2248,6 +2248,13 @@ Example: ...@@ -2248,6 +2248,13 @@ Example:
Fwrappers are used in the implementation of \code{trace} and Fwrappers are used in the implementation of \code{trace} and
\code{profile}. \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} \begin{defmac}{fwrappers:}{define-fwrapper}{name lambda-list \ampbody body}
This macro is like \code{defun}, but defines a function named This macro is like \code{defun}, but defines a function named
\var{name} that can be used as an fwrapper definition. \var{name} that can be used as an fwrapper definition.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment