MethodsList {methods} | R Documentation |
These functions create and manipulate MethodsList
objects, the
objects used in R to store methods for dispatch.
You should not call any of these functions from code that you want to
port to S-Plus. Instead, use the functions described in the
references.
MethodsList(.ArgName, ...) makeMethodsList(object, level=1) SignatureMethod(names, signature, definition) insertMethod(mlist, signature, args, def, whichMethods, fromClass, envir) matchArg(object, thisClass, mlist, ev) matchArgClass(Class, classes, methods) showMlist(mlist, includeDefs = TRUE, inherited = TRUE, classes, useArgNames, printTo = stdout() ) print.MethodsList(x, ...) listFromMlist(mlist, prefix = list()) linearizeMlist(mlist, inherited = TRUE) finalDefaultMethod(mlist, fname = "") mergeMethods(m1, m2)
Note that MethodsList
objects represent methods only in the R
implementation. You can use them to find or manipulate information about
methods, but avoid doing so if you want your code to port to S-Plus.
MethodsList
:
Conceptually, this object is a named collection of methods to be dispatched
when the (first) argument in a function call matches the class corresponding to
one of the names. A final, unnamed element (i.e., with name ""
) corresponds
to the default method.
The elements can be either a function, or another MethodsList. In the second case, this list implies dispatching on the second argument to the function using that list, given a selection of this element on the first argument. Thus, method dispatching on an arbitrary number of arguments is defined.
MethodsList objects are used primarily to dispatch OOP-style methods and, in R, to emulate S4-style methods.
SignatureMethod
:The first argument is the argument names to be used for dispatch corresponding to the signatures.
insertMethod
:def
into the MethodsList object, mlist
, corresponding to
the signature. By default, insert it in the slot which="methods"
,
but cacheMethod
inserts it into the
which="allMethods"
matchArg, matchArgClass
:
showMlist
:includeDefs
the signatures and the
corresonding definitions will be printed; otherwise, only the signatures.
The function calls itself recursively. prev
is the previously
selected classes.
listFromMlistForPrint
:listFromMlist
instead).
The function calls itself recursively: prev
is the previously
selected classes.
finalDefaultMethod
mlist
(the method that matches class "ANY"
for as many arguments as
are used in methods matching for this generic function).mergeMethods
getAllMethods
.
John Chambers
The web page http://www.omegahat.org/RSMethods/index.html is the primary documentation.
The functions in this package emulate the facility for classes and methods described in Programming with Data, (John M. Chambers, Springer, 1998). See this book for further details and examples.