\Header{formals}{Access to and Manipulation of the Formal Arguments}
\alias{formals$\leftarrow $}{formals}
\keyword{programming}{formals}
\begin{Usage}
\begin{verbatim}
formals(fun=sys.function(sys.parent()))
formals(obj) <- list
\end{verbatim}
\end{Usage}
\begin{Value}
If \texttt{fun} is a function then the formal argument list to that
function is returned.
If \texttt{fun} is a character string then the function with that name
is found and used.
If \texttt{fun} is not specified then the function calling \texttt{formals}
is used.

The assignment form sets the formals of a function to the list on the
right hand side.\end{Value}
\begin{SeeAlso}
\texttt{\Link{args}} for a ``human--readable'' version,
\texttt{\Link{alist}}, \texttt{\Link{body}}, \texttt{\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}

