callGeneric | R Documentation |
A call to callGeneric
can only appear inside a method
definition. It then results in a call to the current generic
function. The value of that call is the value of callGeneric
.
While it can be called from any method, it is useful and typically
used in methods for group generic functions.
callGeneric(...)
... |
Optionally, the arguments to the function in its next call. If no arguments are included in the call to |
The name and package of the current generic function is stored in the environment of the method definition object. This name is looked up and the corresponding function called.
The statement that passing no arguments to callGeneric
causes
the generic function to be called with the current arguments is
more precisely as follows. Arguments that were missing in the current
call are still missing (remember that "missing"
is a valid
class in a method signature). For a formal argument, say x
, that
appears in the original call, there is a corresponding argument in the
generated call equivalent to x = x
. In effect, this
means that the generic function sees the same actual arguments, but
arguments are evaluated only once.
Using callGeneric
with no arguments is prone to creating
infinite recursion, unless one of the arguments in the signature has
been modified in the current method so that a different method is selected.
The value returned by the new call.
Chambers, John M. (2016) Extending R, Chapman & Hall. (Chapters 9 and 10.)
Chambers, John M. (2008) Software for Data Analysis: Programming with R Springer. (Section 10.4 for some details.)
GroupGenericFunctions
for other information
about group generic functions; Methods_Details for the general behavior
of method dispatch
## the method for group generic function Ops ## for signature( e1="structure", e2="vector") function (e1, e2) { value <- callGeneric([email protected], e2) if (length(value) == length(e1)) { [email protected] <- value e1 } else value } ## For more examples ## Not run: showMethods("Ops", includeDefs = TRUE) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.