Rev 35751 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{Classes}\alias{Classes}\alias{__ClassMetaData}\title{Class Definitions}\description{Class definitions are objects that contain the formal definition of aclass of R objects.}\details{When a class is defined, an object is stored that contains theinformation about that class, including:\describe{\item{slots}{Each slot is a component object. Like elements of alist these may be extracted (by name) and set. However, theydiffer from list components in important ways.All the objects from a particular class have the same set of slotnames; specifically, the slot names that are contained in theclass definition. Each slot in each object always has the sameclass; again, this is defined by the overall class definition.Classes don't need to have any slots, and many useful classes donot. These objects usually extend other, simple objects, such asnumeric or character vectors. Finally, classes can have no dataat all---these are known as \emph{virtual} classes and are in factvery important programming tools. They are used to group togetherordinary classes that want to share some programming behavior,without necessarily restricting how the behavior is implemented.}\item{extends}{The names of the classes that this class extends. Aclass \code{Fancy}, say, extends a class \code{Simple} if anobject from the \code{Fancy} class has all the capabilities ofthe \code{Simple} class (and probably some more as well). Inparticular, and very usefully, any method defined to work for a\code{Simple} object can be applied to a \code{Fancy} object aswell.In other programming languages, this relationship is sometimesexpressed by saying that \code{Simple} is a superclass of\code{Fancy}, or that \code{Fancy} is a subclass of\code{Simple}.The actual class definition object contains the names of all theclasses this class extends. But those classes can themselvesextend other classes also, so the complete extension can only beknown by obtaining all those class definitions.Class extension is usually defined when the class itself isdefined, by including the names of superclasses as unnamedelements in the representation argument to \code{\link{setClass}}.An object from a given class will then have all the slotsdefined for its own class \emph{and} all the slots defined forits superclasses as well.Note that \code{extends} relations can be defined in other waysas well, by using the \code{\link{setIs}} function.}\item{prototype}{Each class definition contains a prototype objectfrom the class. This must have all the slots, if any, defined bythe class definition.The prototype most commonly just consists of the prototypes of allits slots. But that need not be the case: the definition of theclass can specify any valid object for any of the slots.There are a number of \dQuote{basic} classes, corresponding to theordinary kinds of data occurring in R. For example,\code{"numeric"} is a class corresponding to numeric vectors.These classes are predefined and can then be used as slots or assuperclasses for any other class definitions. The prototypes forthe vector classes are vectors of length 0 of the correspondingtype.There are also a few basic virtual classes, the most importantbeing \code{"vector"}, grouping together all the vector classes;and \code{"language"}, grouping together all the types of objectsmaking up the R language.}}}\references{The web page \url{http://www.omegahat.org/RSMethods/index.html} is theprimary documentation.The functions in this package emulate the facility for classes andmethods described in \emph{Programming with Data} (John M. Chambers,Springer, 1998). See this book for further details and examples.}\author{John Chambers}\seealso{\code{\link{Methods}},\code{\link{setClass}},\code{\link{is}},\code{\link{as}},\code{\link{new}},\code{\link{slot}}}\keyword{programming}\keyword{classes}\keyword{methods}