\Header{formals}{Access to and Manipulation of the Formal Arguments}
\alias{formals<\Rdash}{formals}
\keyword{programming}{formals}
\begin{Description}\relax
Get or set the formal arguments of a function.\end{Description}
\begin{Usage}
\begin{verbatim}
formals(fun = sys.function(sys.parent()))
formals(fun) <- list
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{fun}] a function object or a character string naming the function
to be manipulated.
If not specified, the function calling \code{body} is used.
\item[\code{list}] a list of \R{} expressions.
\end{ldescription}
\end{Arguments}
\begin{Value}
\code{formals} returns the formal argument list of the function
specified.

The assignment form sets the formals of a function to the list on the
right hand side.\end{Value}
\begin{SeeAlso}\relax
\code{\Link{args}} for a ``human-readable'' version,
\code{\Link{alist}},
\code{\Link{body}},
\code{\Link{function}}.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
length(formals(lm))      # the number of formal arguments
names(formals(boxplot))  # formal arguments names

f <- function(x)a+b
formals(f) <- alist(a=,b=3) # function(a,b=3)a+b
f(2) # result = 5
\end{ExampleCode}
\end{Examples}

