The R Project SVN R

Rev

Rev 27733 | Rev 30141 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 27733 Rev 28043
Line 69... Line 69...
69
  %% --------------- grep -nw DispatchGroup src/*/*[ch]
69
  %% --------------- grep -nw DispatchGroup src/*/*[ch]
70
 
70
 
71
  There are four \emph{groups} for which S3 methods can be written,
71
  There are four \emph{groups} for which S3 methods can be written,
72
  namely the \code{"Math"}, \code{"Ops"}, \code{"Summary"} and
72
  namely the \code{"Math"}, \code{"Ops"}, \code{"Summary"} and
73
  \code{"Complex"} groups.  These are not \R objects, but methods can be
73
  \code{"Complex"} groups.  These are not \R objects, but methods can be
74
  supplied for them and base \R contains \code{\link{factor}} and
74
  supplied for them and base \R contains \code{\link{factor}},
75
  \code{\link{data.frame}} methods for the first three groups.
75
  \code{\link{data.frame}} and \code{\link{difftime}} methods for
-
 
76
  the first three groups.
76
  (There is also a \code{\link{ordered}} method for \code{Ops}.)
77
  (There are also a \code{\link{ordered}} method for \code{Ops},
-
 
78
  \code{\link{POSIXt}} methods for \code{Math} and \code{Ops}, as well as a
-
 
79
  \code{\link[stats]{ts}} method for \code{Ops} in package \pkg{stats}.)
77
  
80
  
78
%   A function \emph{\code{f}} belonging to one of these groups must be
81
%   A function \emph{\code{f}} belonging to one of these groups must be
79
%   \code{\link{.Internal}} or \code{\link{.Primitive}} and will
82
%   \code{\link{.Internal}} or \code{\link{.Primitive}} and will
80
%   automatically be using \emph{\code{<grp>.<class> (ob)}} when
83
%   automatically be using \emph{\code{<grp>.<class> (ob)}} when
81
%   \emph{\code{f(<ob>)}} is called, \emph{\code{f}} belongs to group
84
%   \emph{\code{f(<ob>)}} is called, \emph{\code{f}} belongs to group
Line 145... Line 148...
145
      \item \code{Arg}, \code{Conj}, \code{Im}, \code{Mod}, \code{Re}
148
      \item \code{Arg}, \code{Conj}, \code{Im}, \code{Mod}, \code{Re}
146
      % do_cmathfuns() [complex.c:267]: if(DispatchGroup("Complex",...))
149
      % do_cmathfuns() [complex.c:267]: if(DispatchGroup("Complex",...))
147
    }
150
    }
148
  }
151
  }
149
 
152
 
-
 
153
  Note that a method will used for either one of these groups or one of
-
 
154
  its members \emph{only} if it corresponds to a \code{"class"}
-
 
155
  attribute, as the internal code dispatches on \code{\link{oldClass}}
-
 
156
  and not on \code{\link{class}}.  This is for efficiency: having to
-
 
157
  dispatch on, say, \code{Ops.integer} would be too slow.
-
 
158
 
150
  The number of arguments supplied for \code{"Math"} group generic
159
  The number of arguments supplied for \code{"Math"} group generic
151
  methods is not checked prior to dispatch. (Prior to \R 1.7.0, all
160
  methods is not checked prior to dispatch. (Most have default methods
152
  those whose default method has one argument were checked, but the
161
  expecting one argument, but three expect two.)
153
  others were not.)
-
 
154
}
162
}
155
\section{S4 Group Dispatching}{
163
\section{S4 Group Dispatching}{
156
  When package \pkg{methods} is attached, formal (S4) methods can be
164
  When package \pkg{methods} is attached, formal (S4) methods can be
157
  defined for groups.
165
  defined for groups.
158
  
166