| Line 70... |
Line 70... |
| 70 |
\code{NextMethod} should not be called except in methods called by
|
70 |
\code{NextMethod} should not be called except in methods called by
|
| 71 |
\code{UseMethod} or from internal generics (see
|
71 |
\code{UseMethod} or from internal generics (see
|
| 72 |
\link{InternalGenerics}). In particular it will not work inside
|
72 |
\link{InternalGenerics}). In particular it will not work inside
|
| 73 |
anonymous calling functions (e.g. \code{get("print.ts")(AirPassengers)}).
|
73 |
anonymous calling functions (e.g. \code{get("print.ts")(AirPassengers)}).
|
| 74 |
|
74 |
|
| 75 |
Name spaces can register methods for generic functions. To support
|
75 |
Namespaces can register methods for generic functions. To support
|
| 76 |
this, \code{UseMethod} and \code{NextMethod} search for methods in
|
76 |
this, \code{UseMethod} and \code{NextMethod} search for methods in
|
| 77 |
two places: first in the environment in which the generic function
|
77 |
two places: first in the environment in which the generic function
|
| 78 |
is called, and then in the registration data base for the
|
78 |
is called, and then in the registration data base for the
|
| 79 |
environment in which the generic is defined (typically a name space).
|
79 |
environment in which the generic is defined (typically a namespace).
|
| 80 |
So methods for a generic function need to be available in the
|
80 |
So methods for a generic function need to be available in the
|
| 81 |
environment of the call to the generic, or they must be registered.
|
81 |
environment of the call to the generic, or they must be registered.
|
| 82 |
(It does not matter whether they are visible in the environment in
|
82 |
(It does not matter whether they are visible in the environment in
|
| 83 |
which the generic is defined.)
|
83 |
which the generic is defined.)
|
| 84 |
}
|
84 |
}
|