\HeaderA{body}{Access to and Manipulation of the Body of a Function}{body}
\aliasA{body<\Rdash}{body}{body<.Rdash.}
\keyword{programming}{body}
\begin{Description}\relax
Get or set the body of a function.
\end{Description}
\begin{Usage}
\begin{verbatim}
body(fun = sys.function(sys.parent()))
body(fun, envir = parent.frame()) <- value
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{fun}] a function object, or see Details.
\item[\code{envir}] environment in which the function should be defined.
\item[\code{value}] an expression or a list of \R{} expressions.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
For the first form, \code{fun} can be a character string
naming the function to be manipulated, which is searched for from the
parent environment.
If it is not specified, the function calling \code{body} is used.
\end{Details}
\begin{Value}
\code{body} returns the body of the function specified.

The assignment form sets the body of a function to the list on the
right hand side.
\end{Value}
\begin{Note}\relax
For ancient historical reasons, \code{envir = NULL} uses the global
environment rather than the base environment.  
Please use \code{envir = \LinkA{globalenv}{globalenv}()} instead if this is what you want,
as the special handling of \code{NULL} may change in a future release.
\end{Note}
\begin{SeeAlso}\relax
\code{\LinkA{alist}{alist}},
\code{\LinkA{args}{args}},
\code{\LinkA{function}{function}}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
body(body)
f <- function(x) x^5
body(f) <- expression(5^x)
## or equivalently  body(f) <- list(quote(5^x))
f(3) # = 125
body(f)
\end{ExampleCode}
\end{Examples}

