| Line 75... |
Line 75... |
| 75 |
|
75 |
|
| 76 |
While \code{f} can correspond to methods defined on several packages
|
76 |
While \code{f} can correspond to methods defined on several packages
|
| 77 |
or environments, the underlying model is that these together make up
|
77 |
or environments, the underlying model is that these together make up
|
| 78 |
the definition for a single generic function. When R proceeds to
|
78 |
the definition for a single generic function. When R proceeds to
|
| 79 |
select and evaluate methods for \code{f}, the methods on the current
|
79 |
select and evaluate methods for \code{f}, the methods on the current
|
| 80 |
search list are merged to form a single methods list. When \code{f}
|
80 |
search list are merged to form a single generic function and
|
| - |
|
81 |
associated methods list. When \code{f}
|
| 81 |
is called and a method is \dQuote{dispatched}, the evaluator matches the
|
82 |
is called and a method is \dQuote{dispatched}, the evaluator matches the
|
| 82 |
classes of the actual arguments to the signatures of the available
|
83 |
classes of the actual arguments to the signatures of the available
|
| 83 |
methods. When a match is found, the body of the corresponding
|
84 |
methods. When a match is found, the body of the corresponding
|
| 84 |
method is evaluated (in R, the body is evaluated in the lexical
|
85 |
method is evaluated, but without rematching the arguments to
|
| 85 |
context of the method), but without rematching the arguments to
|
86 |
\code{f}. Aside from not rematching the arguments, the computation
|
| - |
|
87 |
proceeds as if the call had been to the method. In particular, the
|
| 86 |
\code{f}.
|
88 |
lexical scope of the method is used.
|
| 87 |
|
89 |
|
| - |
|
90 |
Method definitions can
|
| - |
|
91 |
have default expressions for arguments. If those arguments are then
|
| - |
|
92 |
missing in the call to the generic function, the default expression
|
| - |
|
93 |
in the method is used. If the method definition has no default for
|
| - |
|
94 |
the argument, then the expression (if any) supplied in the definition of the
|
| - |
|
95 |
generic function itself is used. But note that this expression will
|
| - |
|
96 |
be evaluated in the environment defined by the method.
|
| - |
|
97 |
|
| 88 |
It is possible, however, to have some differences between the
|
98 |
It is possible to have some differences between the
|
| 89 |
formal arguments to a method supplied to \code{setMethod} and those
|
99 |
formal arguments to a method supplied to \code{setMethod} and those
|
| 90 |
of the generic. Roughly, if the generic has \dots as one of its
|
100 |
of the generic. Roughly, if the generic has \dots as one of its
|
| 91 |
arguments, then the method may have extra formal arguments, which
|
101 |
arguments, then the method may have extra formal arguments, which
|
| 92 |
will be matched from the arguments matching \dots in the call to
|
102 |
will be matched from the arguments matching \dots in the call to
|
| 93 |
\code{f}. (What actually happens is that a local function is
|
103 |
\code{f}. (What actually happens is that a local function is
|