| Line 66... |
Line 66... |
| 66 |
|
66 |
|
| 67 |
\code{NextMethod} should not be called except in methods called by
|
67 |
\code{NextMethod} should not be called except in methods called by
|
| 68 |
\code{UseMethod}. In particular it will not work inside anonymous
|
68 |
\code{UseMethod}. In particular it will not work inside anonymous
|
| 69 |
calling functions (eg \code{get("print.ts")(AirPassengers)}).
|
69 |
calling functions (eg \code{get("print.ts")(AirPassengers)}).
|
| 70 |
|
70 |
|
| - |
|
71 |
Name spaces can register methods for generic functions. To support
|
| - |
|
72 |
this, \code{UseMethod} and \code{NextMethod} search for methods in
|
| - |
|
73 |
two places: first in the environment in which the generic function
|
| - |
|
74 |
is called, and then in the registration data base for the
|
| - |
|
75 |
environment in which the generic is defined (typically a name space).
|
| - |
|
76 |
So methods for a generic function need to either be available in the
|
| - |
|
77 |
environment of the call to the generic, or they must be registered.
|
| - |
|
78 |
It does not matter whether they are visible in the environment in
|
| - |
|
79 |
which the generic is defined.
|
| - |
|
80 |
|
| 71 |
}
|
81 |
}
|
| 72 |
\note{
|
82 |
\note{
|
| 73 |
This scheme is called \emph{S3} (S version 3). For new projects,
|
83 |
This scheme is called \emph{S3} (S version 3). For new projects,
|
| 74 |
it is recommended to use the more flexible and robust \emph{S4} scheme
|
84 |
it is recommended to use the more flexible and robust \emph{S4} scheme
|
| 75 |
provided in the \pkg{methods} package.
|
85 |
provided in the \pkg{methods} package.
|