| Line 93... |
Line 93... |
| 93 |
If a package defines methods for generic functions, those methods
|
93 |
If a package defines methods for generic functions, those methods
|
| 94 |
should be exported if any of the classes involved are exported; in
|
94 |
should be exported if any of the classes involved are exported; in
|
| 95 |
other words, if someone using the package might expect these methods
|
95 |
other words, if someone using the package might expect these methods
|
| 96 |
to be called.
|
96 |
to be called.
|
| 97 |
Methods are exported by including an \code{exportMethods()} directive
|
97 |
Methods are exported by including an \code{exportMethods()} directive
|
| 98 |
in the \code{NAMESPACE} file for the package, with the arguments to
|
98 |
in the \file{NAMESPACE} file for the package, with the arguments to
|
| 99 |
the directive being the names of the generic functions for which
|
99 |
the directive being the names of the generic functions for which
|
| 100 |
methods have been defined.
|
100 |
methods have been defined.
|
| 101 |
|
101 |
|
| 102 |
Exporting methods is always desirable in the sense of declaring what
|
102 |
Exporting methods is always desirable in the sense of declaring what
|
| 103 |
you want to happen, in that you do expect users to find such methods.
|
103 |
you want to happen, in that you do expect users to find such methods.
|
| 104 |
It can be essential in the case that the method was defined for a
|
104 |
It can be essential in the case that the method was defined for a
|
| 105 |
function that is not originally a generic function in its own package
|
105 |
function that is not originally a formal generic function in its own package
|
| 106 |
(for example, \code{plot()} in the \code{graphics} package). In this
|
106 |
(for example, \code{plot()} in the \pkg{base} package). In this
|
| 107 |
case it may be that the version of the function in the \R session is
|
107 |
case it may be that the version of the function in the \R session is
|
| 108 |
not generic, and your methods will not be called.
|
108 |
not generic, and your methods will not be called.
|
| 109 |
|
109 |
|
| 110 |
Exporting methods for a function also exports the generic version of
|
110 |
Exporting methods for a function also exports the generic version of
|
| 111 |
the function.
|
111 |
the function.
|