| Line 187... |
Line 187... |
| 187 |
to construct a coerce method.
|
187 |
to construct a coerce method.
|
| 188 |
In the usual case that the subclass contains the superclass (i.e., has
|
188 |
In the usual case that the subclass contains the superclass (i.e., has
|
| 189 |
all its slots), the method is constructed either by extracting or
|
189 |
all its slots), the method is constructed either by extracting or
|
| 190 |
replacing the inherited slots.
|
190 |
replacing the inherited slots.
|
| 191 |
Non-simple extensions (the result of a call to \code{\link{setIs}})
|
191 |
Non-simple extensions (the result of a call to \code{\link{setIs}})
|
| 192 |
will usually contain explicit methods, though possibly not for replacement.
|
192 |
will usually contain explicit methods, though possibly not for replacement.
|
| 193 |
|
193 |
|
| 194 |
If no subclass/superclass relationship provides a method, \code{as}
|
194 |
If no subclass/superclass relationship provides a method, \code{as}
|
| 195 |
looks for an inherited method, but applying, inheritance for the argument \code{from} only, not for
|
195 |
looks for an inherited method, but applying, inheritance for the argument \code{from} only, not for
|
| 196 |
the argument \code{to} (if you think about it, you'll probably agree
|
196 |
the argument \code{to} (if you think about it, you'll probably agree
|
| 197 |
that you wouldn't want the result to be from some class other than the
|
197 |
that you wouldn't want the result to be from some class other than the
|
| 198 |
\code{Class} specified). Thus,
|
198 |
\code{Class} specified). Thus,
|
| 199 |
\code{selectMethod("coerce", sig, useInherited= c(from=TRUE, to= FALSE))}
|
199 |
\code{selectMethod("coerce", sig, useInherited= c(from=TRUE, to= FALSE))}
|
| 200 |
replicates the method selection used by \code{as()}.
|
200 |
replicates the method selection used by \code{as()}.
|
| 201 |
|
201 |
|
| 202 |
In nearly all cases the method found in this way will be cached in the
|
202 |
In nearly all cases the method found in this way will be cached in the
|
| 203 |
table of coerce methods (the exception being subclass relationships with a test, which
|
203 |
table of coerce methods (the exception being subclass relationships with a test, which
|
| 204 |
are legal but discouraged).
|
204 |
are legal but discouraged).
|
| 205 |
So the detailed calculations should be done only on the first
|
205 |
So the detailed calculations should be done only on the first
|
| 206 |
occurrence of a coerce from \code{class(object)} to \code{Class}.
|
206 |
occurrence of a coerce from \code{class(object)} to \code{Class}.
|