Classes               package:methods               R Documentation

_C_l_a_s_s _D_e_f_i_n_i_t_i_o_n_s

_D_e_s_c_r_i_p_t_i_o_n:

     Class definitions are objects that contain the formal definition
     of a class of R objects.

_D_e_t_a_i_l_s:

     When a class is defined, an object is stored that contains the
     information about that class, including:

     _s_l_o_t_s Each slot is a component object.  Like elements of a list
          these may be extracted (by name) and set.  However, they
          differ from list components in important ways.

          All the objects from a particular class have the same set of
          slot names; specifically, the slot names that are contained
          in the class definition.  Each slot in each object always has
          the same class; again, this is defined by the overall class
          definition.

          Classes don't need to have any slots, and many useful classes
          do not.  These objects usually extend other, simple objects,
          such as numeric or character vectors.  Finally, classes can
          have no data at all-these are known as _virtual_ classes and
          are in fact very important programming tools.  They are used
          to group together ordinary classes that want to share some
          programming behavior, without necessarily restricting how the
          behavior is implemented.

     _e_x_t_e_n_d_s The names of the classes that this class extends.  A class
          'Fancy', say, extends a class 'Simple' if an object from the
          'Fancy' class has all the capabilities of the 'Simple' class
          (and probably some more as well).  In particular, and very
          usefully, any method defined to work for a 'Simple' object
          can be applied to a 'Fancy' object as well.

          In other programming languages, this relationship is
          sometimes expressed by saying that 'Simple' is a superclass
          of 'Fancy', or that 'Fancy' is a subclass of 'Simple'.

          The actual class definition object contains the names of all
          the classes this class extends.  But those classes can
          themselves extend other classes also, so the complete
          extension can only be known by obtaining all those class
          definitions.

          Class extension is usually defined when the class itself is
          defined, by including the names of superclasses as unnamed
          elements in the representation argument to 'setClass'.

          An object from a given class will then have all the slots
          defined for its own class _and_ all the slots defined for its
          superclasses as well.

          Note that 'extends' relations can be defined in other ways as
          well, by using the 'setIs' function.

     _p_r_o_t_o_t_y_p_e Each class definition contains a prototype object from
          the class.  This must have all the slots, if any, defined by
          the class definition.

          The prototype most commonly just consists of the prototypes
          of all its slots.  But that need not be the case:  the
          definition of the class can specify any valid object for any
          of the slots.

          There are a number of "basic" classes, corresponding to the
          ordinary kinds of data occurring in R.  For example,
          '"numeric"' is a class corresponding to numeric vectors.
          These classes are predefined and can then be used as slots or
          as superclasses for any other class definitions.  The
          prototypes for the vector classes are vectors of length 0 of
          the corresponding type.

          There are also a few basic virtual classes, the most
          important being '"vector"', grouping together all the vector
          classes; and '"language"', grouping together all the types of
          objects making up the R language.

_A_u_t_h_o_r(_s):

     John Chambers

_R_e_f_e_r_e_n_c_e_s:

     The web page <URL: http://www.omegahat.org/RSMethods/index.html>
     is the primary documentation.

     The functions in this package emulate the facility for classes and
     methods described in _Programming with Data_ (John M. Chambers,
     Springer, 1998).  See this book for further details and examples.

_S_e_e _A_l_s_o:

     'Methods', 'setClass', 'is', 'as', 'new', 'slot'

