The R Project SVN R

Rev

Rev 42333 | Rev 43625 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 42333 Rev 42389
Line 99... Line 99...
99
}
99
}
100
\value{
100
\value{
101
  Function \code{implicitGeneric()} returns the implicit generic
101
  Function \code{implicitGeneric()} returns the implicit generic
102
  definition (and caches that definition the first time if it has to
102
  definition (and caches that definition the first time if it has to
103
  construct it).
103
  construct it).
104
  
104
 
105
  The other functions exist for their side effect and return nothing
105
  The other functions exist for their side effect and return nothing
106
  useful.
106
  useful.
107
}
107
}
108
\seealso{\code{\link{setGeneric}}}
108
\seealso{\code{\link{setGeneric}}}
109
\examples{
109
\examples{
-
 
110
 
-
 
111
### How we would make the function \link{with}() into a generic:
-
 
112
 
-
 
113
## Since the second argument, 'expr' is used literally, we want
-
 
114
## with() to only have "data" in the signature.
-
 
115
 
-
 
116
## Note that 'methods'-internal code now has already extended  with()
-
 
117
## to do the equivalent of the following
110
\dontrun{
118
\dontrun{
111
### How we would make the function \link{with}() into a generic
-
 
112
### The second argument is used literally, so we want it to have
-
 
113
### only "data" in the signature.
-
 
114
setGeneric("with", signature = "data")
119
setGeneric("with", signature = "data")
115
### Now we could predefine methods for "with" if we wanted to.
120
## Now we could predefine methods for "with" if we wanted to.
116
 
121
 
117
### When ready, we store the generic as implicit,
122
## When ready, we store the generic as implicit, and restore the original
118
### and restore the original
-
 
119
setGenericImplicit("with")
123
setGenericImplicit("with")
120
 
124
 
121
### (This example would only work if we "owned" function with(),
125
## (This example would only work if we "owned" function with(),
122
### but it is in base.)}
126
##  but it is in base.)}
123
 
127
 
124
implicitGeneric("with")
128
implicitGeneric("with")
125
}
129
}
-
 
130
 
126
\keyword{programming}
131
\keyword{programming}
127
\keyword{methods}
132
\keyword{methods}