The R Project SVN R

Rev

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

Rev 68948 Rev 70994
Line 1... Line 1...
1
% File src/library/methods/man/getMethod.Rd
1
% File src/library/methods/man/getMethod.Rd
2
% Part of the R package, https://www.R-project.org
2
% Part of the R package, https://www.R-project.org
3
% Copyright 1995-2012 R Core Team
3
% Copyright 1995-2016 R Core Team
4
% Distributed under GPL 2 or later
4
% Distributed under GPL 2 or later
5
 
5
 
6
\name{getMethod}
6
\name{getMethod}
-
 
7
\title{Get or Test for the Definition of a Method}
7
\alias{getMethod}
8
\alias{getMethod}
8
\alias{findMethod}
9
\alias{findMethod}
9
\alias{existsMethod}
10
\alias{existsMethod}
10
\alias{selectMethod}
11
\alias{selectMethod}
11
\alias{hasMethod}
12
\alias{hasMethod}
12
\title{ Get or Test for the Definition of a Method }
-
 
13
\description{
13
\description{
14
  Functions to look for a method corresponding to a given generic function and signature.
14
  Functions to look for a method corresponding to a given generic function and signature.
15
  The functions \code{getMethod} and \code{selectMethod} return the method; the functions
15
  The functions \code{getMethod} and \code{selectMethod} return the method; the functions
16
  \code{existsMethod} and \code{hasMethod} test for its existence.  In both
16
  \code{existsMethod} and \code{hasMethod} test for its existence.  In both
17
  cases the first function only gets direct definitions and the second
17
  cases the first function only gets direct definitions and the second
Line 21... Line 21...
21
  The function \code{findMethod} returns the package(s) in the search
21
  The function \code{findMethod} returns the package(s) in the search
22
  list (or in the packages specified by the \code{where} argument) that
22
  list (or in the packages specified by the \code{where} argument) that
23
  contain a method for this function and signature.
23
  contain a method for this function and signature.
24
}
24
}
25
\usage{
25
\usage{
26
getMethod(f, signature=character(), where, optional = FALSE,
-
 
27
          mlist, fdef)
-
 
28
 
-
 
29
existsMethod(f, signature = character(), where)
26
existsMethod(f, signature = character(), where)
30
 
27
 
31
findMethod(f, signature, where)
28
  findMethod(f, signature, where)
32
 
29
 
33
selectMethod(f, signature, optional = FALSE, useInherited =,
30
   getMethod(f, signature = character(), where, optional = FALSE, mlist, fdef)
34
             mlist = , fdef = , verbose = , doCache = )
-
 
35
 
31
 
36
hasMethod(f, signature=character(), where)
32
   hasMethod(f, signature = character(), where)
37
 
33
 
-
 
34
selectMethod(f, signature, optional = FALSE, useInherited =,
-
 
35
             mlist = , fdef = , verbose = , doCache = )
38
}
36
}
39
\arguments{
37
\arguments{
40
  \item{f}{A  generic function or the character-string name of one.}
38
  \item{f}{a generic function or the character-string name of one.}
41
  \item{signature}{the signature of classes to match to the arguments
39
  \item{signature}{the signature of classes to match to the arguments
42
    of \code{f}.  See the details below.
40
    of \code{f}.  See the details below.}
43
 
-
 
44
  }
-
 
45
  \item{where}{The position or environment in which to look for the
41
  \item{where}{the position or environment in which to look for the
46
    method(s):  by default, the table of methods defined in the generic function itself is used.}
42
    method(s):  by default, the table of methods defined in the generic
-
 
43
    function itself is used.}
47
 
44
 
48
  \item{optional}{If the selection in \code{selectMethod} does not find a valid method
45
  \item{optional}{if the selection in \code{selectMethod} does not find
49
    an error is generated, unless this argument is \code{TRUE}.  In that
46
    a valid method an error is generated, unless \code{optional} is
50
    case, the value returned is \code{NULL} if no method matches.}
47
    true.  In that case, the value returned is \code{NULL} if no method
-
 
48
    matches.}
51
  \item{mlist, fdef, useInherited, verbose, doCache}{Optional
49
  \item{mlist, fdef, useInherited, verbose, doCache}{optional arguments
52
      arguments  to  \code{getMethod} and \code{selectMethod} for
50
    to  \code{getMethod} and \code{selectMethod} for internal use.  Avoid
53
      internal use.  Avoid
51
    these: some will work as expected and others will not, and none of
54
      these: some will work as expected and others will not, and none of them is required for normal use of the functions.
52
    them is required for normal use of the functions.}
55
    }
-
 
56
 
-
 
57
}
53
}
58
\details{
54
\details{
59
  The \code{signature} argument specifies classes, corresponding to formal arguments of the generic function; to be precise, to the \code{signature} slot of the generic function object.
55
  The \code{signature} argument specifies classes, corresponding to
60
    The argument may be a vector of strings identifying
56
  formal arguments of the generic function; to be precise, to the
-
 
57
  \code{signature} slot of the generic function object.  The argument
61
    classes, and may be named or not.  Names, if supplied, match the
58
  may be a vector of strings identifying classes, and may be named or
62
    names of those formal arguments included in the signature of the
59
  not.  Names, if supplied, match the names of those formal arguments
63
    generic.  That signature is normally all the arguments except
60
  included in the signature of the generic.  That signature is normally
64
    \dots.  However, generic functions can be specified with only a
61
  all the arguments except \dots.  However, generic functions can be
65
    subset of the arguments permitted, or with the signature taking
62
  specified with only a subset of the arguments permitted, or with the
66
    the arguments in a different order.
63
  signature taking the arguments in a different order.
67
 
64
 
68
    It's a good idea to name the arguments in the signature to avoid
65
  It's a good idea to name the arguments in the signature to avoid
69
    confusion, if you're dealing with a generic that does something
66
  confusion, if you're dealing with a generic that does something
70
    special with its signature.   In any case, the elements of the
67
  special with its signature.  In any case, the elements of the
71
    signature are matched to the formal signature by the same rules
68
  signature are matched to the formal signature by the same rules used
72
    used in matching arguments in function calls (see
69
  in matching arguments in function calls (see
73
    \code{\link{match.call}}).
70
  \code{\link{match.call}}).
74
 
71
 
75
    The strings in the signature may be class names, \code{"missing"}
72
  The strings in the signature may be class names, \code{"missing"} or
76
    or \code{"ANY"}.  See \link{Methods} for the meaning of these in
73
  \code{"ANY"}.  See \link{Methods} for the meaning of these in method
77
    method selection.  Arguments not supplied in the signature
74
  selection.  Arguments not supplied in the signature implicitly
78
    implicitly correspond to class \code{"ANY"}; in particular, giving
75
  correspond to class \code{"ANY"}; in particular, giving an empty
79
    an empty signature means to look for the default method.
76
  signature means to look for the default method.
80
 
77
 
81
  A call to \code{getMethod} returns the method for a particular
78
  A call to \code{getMethod} returns the method for a particular
82
  function and signature.  As with other \code{get} functions,
79
  function and signature.  As with other \code{get} functions,
83
  argument \code{where} controls where the function looks (by default
80
  argument \code{where} controls where the function looks (by default
84
  anywhere in the search list) and argument \code{optional} controls
81
  anywhere in the search list) and argument \code{optional} controls