\Header{environment}{Environment Access}
\alias{environment$\leftarrow $}{environment}
\alias{.GlobalEnv}{environment}
\alias{globalenv}{environment}
\alias{is.environment}{environment}
\keyword{data}{environment}
\keyword{programming}{environment}
\begin{Usage}
\begin{verbatim}
environment(fun = NULL)
environment(fun) <- value
is.environment(obj)
.GlobalEnv
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\texttt{fun}] a \texttt{\Link{function}} or \texttt{NULL}, which is the default.
\end{ldescription}
\end{Arguments}
\begin{Value}
If \texttt{fun} is a function then \texttt{environment(fun)}
returns the environment associated with that function.
If \texttt{fun} is \texttt{NULL} then the global environment, \texttt{.GlobalEnv},
is returned. This variable is currently defined as \texttt{globalenv()}.

The assignment form sets the environment of the function \texttt{fun}
to the \texttt{value} given.  \texttt{is.environment(obj)} returns \texttt{TRUE}
iff \texttt{obj} is an \texttt{environment}.\end{Value}
\begin{SeeAlso}
The \texttt{envir} argument of \texttt{\Link{eval}}.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
##-- all three give the same:
environment()
environment(environment)
.GlobalEnv

ls(envir=environment(approxfun(1:2,1:2, method="const")))

is.environment(.GlobalEnv)# T
\end{ExampleCode}
\end{Examples}

