Rev 16302 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{MethodsList}\alias{MethodsList}\alias{makeMethodsList}\alias{SignatureMethod}\alias{insertMethod}\alias{MethodsListDispatch}\alias{matchArg}\alias{matchArgClass}\alias{showMlist}\alias{print.MethodsList}\alias{emptyMethodsList}\alias{insertMethodInEmptyList}\alias{listFromMlistForPrint}\title{MethodsList Objects}\usage{MethodsList(.ArgName, ...)makeMethodsList(object, level=1)SignatureMethod(names, signature, definition)insertMethod(mlist, signature, args, def)MethodsListDispatch(fname, ev, mustFind = TRUE)matchArg(object, methods, defaultMethod)matchArgClass(Class, methods, defaultMethod)showMlist(mlist, includeDefs=TRUE, inherited = TRUE)print.MethodsList(x, ...)listFromMlistForPrint(mlist, inherited = TRUE, useArgName = TRUE, prev = character())}\description{These functions create and manipulate \code{MethodsList} objects, theobjects used in R to store methods for dispatch.You should not call any of these functions from code that you want toport to S-Plus. Instead, use the functions described in thedocumentation.\describe{\item{\code{MethodsList}:}{Create a MethodsList object out of the arguments.Conceptually, this object is a named collection of methods to be dispatchedwhen the (first) argument in a function call matches the class corresponding toone of the names. A final, unnamed element (i.e., with name \code{""}) correspondsto 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 thatlist, given a selection of this element on the first argument. Thus, method dispatchingon 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.}\item{\code{SignatureMethod}:}{construct a MethodsList object containing (only) this method, correspondingto the signature; i.e., such that signature[[1]] is the match for the firstargument, signature[[2]] for the second argument, and so on. The string"missing" means a match for a missing argument, and "ANY" means use this as thedefault setting at this level.The first argument is the argument names to be used for dispatch corresponding tothe signatures.}\item{\code{insertMethod}:}{insert the definition \code{def} into the MethodsList object, \code{mlist}, corresponding tothe signature}\item{\code{MethodsListDispatch}:}{select the element of a MethodsList object corresponding to theactual arguments.Works recursively. At each level finds an argument name from the current \code{mlist}object, and evaluates this argument (if it is not missing), then uses the\code{data.class} of the result to select an element of \code{mlist}. If such an elementexists and is another \code{MethodsList} object, \code{MethodsListDispatch} calls itself recursivelyto resolve using further arguments. Matching includes using a default selection ora method specifically linked to class \code{"missing"}. Once a function is found, itis returned as the value. If matching fails, an error occurs.}\item{\code{matchArg, matchArgClass}:}{Utility functions to match the object or the class to the elements ofa methods list.Used in finding inherited methods, and not meant to be called directly.}\item{\code{showMlist}:}{Prints the contents of the MethodsList. If \code{includeDefs} the signatures and thecorresonding definitions will be printed; otherwise, only the signatures.The function calls itself recursively. \code{prev} is the previouslyselected classes.}\item{\code{listFromMlistForPrint}:}{Undo the recursive nature of the methods list, making a list of functiondefintions, with the names of the list being the corresponding signatures(designed for printing; for looping over the methods, use \code{\link{listFromMlist}} instead).The function calls itself recursively: \code{prev} is the previouslyselected classes.}}}\details{Note that \code{MethodsList} objects represent methods only in the \Rimplementation. You can use them to find or manipulate information aboutmethods, but avoid doing so if you want your code to port to S-Plus.}\references{The web page \url{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\emph{Programming with Data}, (John M. Chambers, Springer, 1998). See this bookfor further details and examples.}\author{John Chambers}\examples{}\keyword{programming}\keyword{classes}\keyword{methods}