\HeaderA{isS4}{Test for an S4 object}{isS4}
\aliasA{asS4}{isS4}{asS4}
\keyword{programming}{isS4}
\begin{Description}\relax
Tests whether the object was created from a formally defined class.
\end{Description}
\begin{Usage}
\begin{verbatim}
isS4(object)

asS4(object, value = TRUE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{object}] Any R object. 
\item[\code{value}] A single logical value; not \code{NA}.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Note that \code{isS4} does not rely on the \pkg{methods}
package, so in particular it can be used to detect the need to
\code{\LinkA{require}{require}} that package.  (But \code{asS4} does depend on
\pkg{methods}.)

You should not set the flag directly unless you really know why.  As
from \R{} 2.6.0, S4 methods are restricted to S4 objects for primitive
functions; \code{asS4} allows method dispatch of S4 methods on
primitives for S3 classes. For all other purposes, an object will
satisfy \code{isS4(x)} if and only if it should.
\end{Details}
\begin{Value}
\code{isS4} always returns \code{TRUE} or \code{FALSE} according to
whether the internal flag marking an S4 object has been turned on for
this object.

\code{asS4} will turn this flag on or off. But see the details.
\end{Value}
\begin{Examples}
\begin{ExampleCode}

isS4(pi) # FALSE
isS4(getClass("MethodDefinition")) # TRUE

\end{ExampleCode}
\end{Examples}

