\Header{match.fun}{Function Verification for ``Function Variables''}
\keyword{programming}{match.fun}
\begin{Usage}
\begin{verbatim}
match.fun(FUN, descend=TRUE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\texttt{FUN}] function, e.g. as passed to \texttt{\Link{outer}}.
\item[\texttt{descend}] logical; control whether to search under non-function
objects.
\end{ldescription}
\end{Arguments}
\begin{Description}
Matches \texttt{FUN} to a function, where \texttt{FUN} can be a
character (string), e.g., \texttt{"*"} or \texttt{"fred"},
or a function such as \texttt{pmax}.

Returns an error if no matching function is found.\end{Description}
\begin{Details}
If \texttt{descend=TRUE}, \texttt{match.fun} will look underneath
non-function objects with the given name; otherwise if \texttt{FUN}
points to a non-function object then an error is generated.

This is now used in base functions such as
\texttt{\Link{apply}}, \texttt{\Link{lapply}}, \texttt{\Link{outer}},
\texttt{\Link{sweep}}, and the like.\end{Details}
\begin{Value}
A function matching \texttt{FUN} or an error is generated.\end{Value}
\begin{Section}{Bug/Feature}
A character argument to \texttt{FUN} is always matched to a
function, even if there is a non-function object higher up the
search list with the same name.\end{Section}
\begin{Author}
Jonathan Rougier\end{Author}
\begin{SeeAlso}
\texttt{\Link{match.arg}}\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
# Same as get("*"):
match.fun("*")
# Overwrite outer with a vector
outer <- 1:5

match.fun(outer, descend = FALSE) #-> Error:  not a function

match.fun(outer) # finds it anyway
is.function(match.fun("outer")) # as well
\end{ExampleCode}
\end{Examples}

