| Line 72... |
Line 72... |
| 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 |
Namespaces 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: in the environment in which the generic function
|
| 78 |
is called, and then in the registration data base for the
|
78 |
is called, and in the registration data base for the
|
| 79 |
environment in which the generic is defined (typically a namespace).
|
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.) As from \R 3.5.0, the registration
|
| - |
|
84 |
data base is searched after the top level environment (see
|
| - |
|
85 |
\code{\link{topenv}}) of the calling environment (but before the
|
| - |
|
86 |
parents of the top level environment).
|
| 84 |
}
|
87 |
}
|
| 85 |
\section{Technical Details}{
|
88 |
\section{Technical Details}{
|
| 86 |
Now for some obscure details that need to appear somewhere. These
|
89 |
Now for some obscure details that need to appear somewhere. These
|
| 87 |
comments will be slightly different than those in Chambers(1992).
|
90 |
comments will be slightly different than those in Chambers(1992).
|
| 88 |
(See also the draft \sQuote{R Language Definition}.)
|
91 |
(See also the draft \sQuote{R Language Definition}.)
|