The R Project SVN R

Rev

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

Rev 31891 Rev 33634
Line 11... Line 11...
11
\alias{dumpMethods}
11
\alias{dumpMethods}
12
\alias{removeMethods}
12
\alias{removeMethods}
13
\alias{signature}
13
\alias{signature}
14
\alias{setReplaceMethod}
14
\alias{setReplaceMethod}
15
\alias{callGeneric}
15
\alias{callGeneric}
-
 
16
%% FIXME:  These are basically not documented at all:
-
 
17
%% -----  isGroup, setReplaceMethod, allGenerics
16
\title{Tools for Managing Generic Functions}
18
\title{Tools for Managing Generic Functions}
17
\description{
19
\description{
18
  The functions documented here manage collections of methods associated
20
  The functions documented here manage collections of methods associated
19
  with a generic function, as well as providing information about the
21
  with a generic function, as well as providing information about the
20
  generic functions themselves.
22
  generic functions themselves.
21
}
23
}
22
\synopsis{
-
 
23
isGeneric(f, where, fdef, getName = FALSE)
-
 
24
isGroup(f, where, fdef)
-
 
25
removeGeneric(f, where)
-
 
26
dumpMethod(f, signature, file, where, def)
-
 
27
findFunction(f, generic=TRUE, where)
-
 
28
dumpMethods(f, file, signature, methods, where)
-
 
29
signature(\dots)
-
 
30
removeMethods(f, where, all)
-
 
31
setReplaceMethod(f, \dots, where)
-
 
32
getGenerics(where, searchForm = FALSE)
-
 
33
allGenerics(where, searchForm = FALSE)
-
 
34
callGeneric(\dots)
-
 
35
}
-
 
36
\usage{
24
\usage{
37
isGeneric(f, where, fdef, getName = FALSE)
25
isGeneric(f, where, fdef, getName = FALSE)
38
 
-
 
39
isGroup(f, where, fdef)
26
isGroup(f, where, fdef)
40
 
-
 
41
removeGeneric(f, where)
27
removeGeneric(f, where)
42
 
-
 
43
standardGeneric(f)
28
standardGeneric(f)
44
 
29
 
45
dumpMethod(f, signature, file, where, def)
30
dumpMethod(f, signature, file, where, def)
46
 
-
 
47
findFunction(f, generic=TRUE)
31
findFunction(f, generic=TRUE)
48
 
-
 
49
dumpMethods(f, file, signature, methods, where)
32
dumpMethods(f, file, signature, methods, where)
50
 
-
 
51
signature(\dots)
33
signature(\dots)
52
 
34
 
53
removeMethods(f, where)
35
removeMethods(f, where)
54
 
-
 
55
setReplaceMethod(f, \dots)
36
setReplaceMethod(f, \dots)
56
 
37
 
57
getGenerics(where, searchForm = FALSE)
38
getGenerics(where, searchForm = FALSE)
58
 
-
 
59
allGenerics(where, searchForm = FALSE)
39
allGenerics(where, searchForm = FALSE)
60
 
-
 
61
callGeneric(\dots)
40
callGeneric(\dots)
62
 
-
 
63
}
41
}
64
\section{Summary of Functions}{
42
\section{Summary of Functions}{
65
  \describe{
43
  \describe{
66
    \item{\code{isGeneric}:}{
44
    \item{\code{isGeneric}:}{
67
      Is there a function named \code{f}, and if so, is it a generic?
45
      Is there a function named \code{f}, and if so, is it a generic?
Line 94... Line 72...
94
      Dispatches a method from the current function call for the generic
72
      Dispatches a method from the current function call for the generic
95
      function \code{f}.  It is an error to call
73
      function \code{f}.  It is an error to call
96
      \code{standardGeneric} anywhere except in the body of the
74
      \code{standardGeneric} anywhere except in the body of the
97
      corresponding generic function.
75
      corresponding generic function.
98
    }
76
    }
99
    \item{\code{getMethods}:}{
-
 
100
      The list of methods for the specified generic.
-
 
101
    }
-
 
102
    \item{\code{dumpMethod}:}{
77
    \item{\code{dumpMethod}:}{
103
      Dump the method for this generic function and signature.
78
      Dump the method for this generic function and signature.
104
    }
79
    }
105
    \item{\code{findFunction}:}{
80
    \item{\code{findFunction}:}{
106
      return a list of either the positions on the search list, or the
81
      return a list of either the positions on the search list, or the
Line 113... Line 88...
113
      \code{mode="function"}, which is not as meaningful, and has a few
88
      \code{mode="function"}, which is not as meaningful, and has a few
114
      subtle bugs from its use of regular expressions.  Also,
89
      subtle bugs from its use of regular expressions.  Also,
115
      \code{findFunction} works correctly in the code for a package
90
      \code{findFunction} works correctly in the code for a package
116
      when attaching the package via a call to \code{\link{library}}.
91
      when attaching the package via a call to \code{\link{library}}.
117
    }
92
    }
118
    \item{\code{selectMethod}:}{
-
 
119
      Returns the method (a function) that R would use to evaluate a
-
 
120
      call to this generic, with arguments corresponding to the
-
 
121
      specified signature.
-
 
122
 
-
 
123
      \code{f} = the name of the generic function, \code{signature} is
-
 
124
      the signature of classes to match to the arguments of \code{f}.
-
 
125
    }
-
 
126
    \item{\code{dumpMethods}:}{
93
    \item{\code{dumpMethods}:}{
127
      Dump all the methods for this generic.
94
      Dump all the methods for this generic.
128
    }
95
    }
129
    \item{\code{signature}:}{
96
    \item{\code{signature}:}{
130
      Returns a named list of classes to be matched to arguments of a
97
      Returns a named list of classes to be matched to arguments of a
131
      generic function.
98
      generic function.
132
    }
99
    }
133
      \item{\code{getGenerics}:}{ Returns the names of the generic
100
    \item{\code{getGenerics}:}{ Returns the names of the generic
134
          functions that have methods defined on \code{where}; this
101
      functions that have methods defined on \code{where}; this
135
          argument can be an environment or an index into the search
102
      argument can be an environment or an index into the search
136
          list.  By default, the whole search list is used.
103
      list.  By default, the whole search list is used.
137
 
104
 
138
          The methods definitions are stored with
105
      The methods definitions are stored with
139
          package qualifiers; for example, methods for function
106
      package qualifiers; for example, methods for function
140
          \code{"initialize"} might refer to two different functions
107
      \code{"initialize"} might refer to two different functions
141
          of that name, on different packages.  The package names
108
      of that name, on different packages.  The package names
142
          corresponding to the method list object are contained in the
109
      corresponding to the method list object are contained in the
143
           slot \code{package} of the returned object.  The form of
110
      slot \code{package} of the returned object.  The form of
144
           the returned name can be plain (e.g., \code{"base"}), or in
111
      the returned name can be plain (e.g., \code{"base"}), or in
145
           the form used in the search list (\code{"package:base"})
112
      the form used in the search list (\code{"package:base"})
146
           according to the value of \code{searchForm}}
113
      according to the value of \code{searchForm}}
147
    \item{\code{callGeneric}:}{
114
    \item{\code{callGeneric}:}{
148
      In the body of a method, this function will make a call to the
115
      In the body of a method, this function will make a call to the
149
      current generic function.  If no arguments are passed to
116
      current generic function.  If no arguments are passed to
150
      \code{callGeneric}, the arguments to the current call are passed
117
      \code{callGeneric}, the arguments to the current call are passed
151
      down; otherwise, the arguments are interpreted as in a call to the
118
      down; otherwise, the arguments are interpreted as in a call to the
Line 234... Line 201...
234
 
201
 
235
      The usual \code{setGeneric} (directly or through calling
202
      The usual \code{setGeneric} (directly or through calling
236
      \code{setMethod}) creates a function with a call to
203
      \code{setMethod}) creates a function with a call to
237
      \code{standardGeneric}.
204
      \code{standardGeneric}.
238
    }
205
    }
239
    \item{\code{getMethods}:}{
-
 
240
      If the function is not a generic function, returns \code{NULL}.
-
 
241
      The \code{f} argument can be either the character string name of
-
 
242
      the generic or the object itself.
-
 
243
 
-
 
244
      The \code{where} argument optionally says where to look for the
-
 
245
      function, if \code{f} is given as the name.
-
 
246
    }
-
 
247
    \item{\code{dumpMethod}:}{
206
    \item{\code{dumpMethod}:}{
248
      The resulting source file will recreate the method.
207
      The resulting source file will recreate the method.
249
    }
208
    }
250
    \item{\code{findFunction}:}{
209
    \item{\code{findFunction}:}{
251
      If \code{generic} is \code{FALSE}, ignore generic functions.
210
      If \code{generic} is \code{FALSE}, ignore generic functions.
252
    }
211
    }
253
    \item{\code{selectMethod}:}{
-
 
254
      The vector of strings for the classes can be named or not.  If
-
 
255
      named, the names must match formal argument names of \code{f}.  If
-
 
256
      not named, the signature is assumed to apply to the arguments of
-
 
257
      \code{f} in order.
-
 
258
 
-
 
259
      If \code{mustFind} is \code{TRUE}, an error results if there is no
-
 
260
      method (or no unique method) corresponding to this signature.
-
 
261
      Otherwise may return \code{NULL} or a MethodsList object.
-
 
262
    }
-
 
263
    \item{\code{dumpMethods}:}{
212
    \item{\code{dumpMethods}:}{
264
      If \code{signature} is supplied only the methods matching this
213
      If \code{signature} is supplied only the methods matching this
265
      initial signature are dumped.  (This feature is not found in
214
      initial signature are dumped.  (This feature is not found in
266
      S-Plus:  don't use it if you want compatibility.)
215
      S-Plus:  don't use it if you want compatibility.)
267
    }
216
    }
Line 299... Line 248...
299
  discussion of details and ongoing development, see the web page
248
  discussion of details and ongoing development, see the web page
300
  \url{http://developer.r-project.org/methodsPackage.html} and the
249
  \url{http://developer.r-project.org/methodsPackage.html} and the
301
  pointers from that page.
250
  pointers from that page.
302
}
251
}
303
\seealso{
252
\seealso{
-
 
253
  \code{\link{getMethod}} (also for \code{selectMethod}),
304
  \code{\link{setGeneric}},
254
  \code{\link{setGeneric}},
305
  \code{\link{setClass}},
255
  \code{\link{setClass}},
306
  \code{\link{showMethods}}
256
  \code{\link{showMethods}}
307
}
257
}
308
\examples{
258
\examples{