\HeaderA{as.function}{Convert Object to Function}{as.function}
\methaliasA{as.function.default}{as.function}{as.function.default}
\keyword{programming}{as.function}
\begin{Description}\relax
\code{as.function} is a generic function which is used to convert
objects to functions.

\code{as.function.default} works on a list \code{x}, which should contain the
concatenation of a formal argument list and an expression or an
object of mode \code{"\LinkA{call}{call}"} which will become the function body.
The function will be defined in a specified environment, by default
that of the caller.
\end{Description}
\begin{Usage}
\begin{verbatim}
as.function(x, ...)

## Default S3 method:
as.function(x, envir = parent.frame(), ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] object to convert, a list for the default method.
\item[\code{...}] additional arguments, depending on object
\item[\code{envir}] environment in which the function should be defined
\end{ldescription}
\end{Arguments}
\begin{Value}
The desired function.
\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{Author}\relax
Peter Dalgaard
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{function}{function}};
\code{\LinkA{alist}{alist}} which is handy for the construction of
argument lists, etc.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
as.function(alist(a=,b=2,a+b))
as.function(alist(a=,b=2,a+b))(3)
\end{ExampleCode}
\end{Examples}

