\HeaderA{autoload}{On-demand Loading of Packages}{autoload}
\aliasA{.Autoloaded}{autoload}{.Autoloaded}
\aliasA{.AutoloadEnv}{autoload}{.AutoloadEnv}
\aliasA{autoloader}{autoload}{autoloader}
\aliasA{Autoloads}{autoload}{Autoloads}
\keyword{data}{autoload}
\keyword{programming}{autoload}
\begin{Description}\relax
\code{autoload} creates a promise-to-evaluate \code{autoloader} and
stores it with name \code{name} in \code{.AutoloadEnv} environment.
When \R{} attempts to evaluate \code{name}, \code{autoloader} is run,
the package is loaded and \code{name} is re-evaluated in the new
package's environment.  The result is that \R{} behaves as if
\code{file} was loaded but it does not occupy memory.

\code{.Autoloaded} contains the names of the packages for
which autoloading has been promised.
\end{Description}
\begin{Usage}
\begin{verbatim}
autoload(name, package, reset = FALSE, ...)
autoloader(name, package, ...)

.AutoloadEnv
.Autoloaded
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{name}] string giving the name of an object.
\item[\code{package}] string giving the name of a package containing the object.
\item[\code{reset}] logical: for internal use by \code{autoloader}.
\item[\code{...}] other arguments to \code{\LinkA{library}{library}}.
\end{ldescription}
\end{Arguments}
\begin{Value}
This function is invoked for its side-effect.  It has no return value.
\end{Value}
\begin{SeeAlso}\relax
\code{\LinkA{delayedAssign}{delayedAssign}}, \code{\LinkA{library}{library}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
require(stats)
autoload("interpSpline", "splines")
search()
ls("Autoloads")
.Autoloaded

x <- sort(stats::rnorm(12))
y <- x^2
is <- interpSpline(x,y)
search() ## now has splines
detach("package:splines")
search()
is2 <- interpSpline(x,y+x)
search() ## and again
detach("package:splines")
\end{ExampleCode}
\end{Examples}

