Rev 50418 | Rev 51322 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
% File src/library/methods/man/findMethods.Rd% Part of the R package, http://www.R-project.org% Copyright 2008 R Core Development Team% Distributed under GPL 2 or later\name{findMethods}\alias{findMethods}\alias{findMethodSignatures}\alias{hasMethods}\alias{getMethods}\title{Descriptions of the Methods Defined for a Generic Function}\description{These functions convert the methods defined in a table for a genericfunction (as used for selection of methods) into a list, for study ordisplay, or provide other information summarizing the methods.The function \code{findMethods} returns a list of the methoddefinitions currently existing for generic function \code{f}, limitedto the methods defined in environment \code{where} if that argument issupplied and possibly limited to those including one or more of thespecified \code{classes} in the method signature.The function \code{findMethodSignatures} returns a character matrixwhose rows are the class names from the signature of the correspondingmethods; it operates either from a list returned by\code{findMethods}, or by computing such a list itself, given the samearguments as \code{findMethods} .The function \code{hasMethods} returns \code{TRUE} or \code{FALSE}according to whether there is a non-empty table of methods forfunction \code{f} in the environment or search position \code{where}(or anywhere on the search list if \code{where} is missing).The function \code{getMethods} is an older alternative to\code{findMethods} , returning information in the form of an object ofclass \code{MethodsList}, previously used for method dispatch. It isnot recommended, since the object returned is usually less convenientthan the value of \code{findMethods}. To see the actual table usedfor methods dispatch, either use the \code{table = TRUE} option to\code{getMethods} or call \code{\link{getMethodsForDispatch}} instead.}\usage{findMethods(f, where, classes = character(), inherited = FALSE)findMethodSignatures(..., target = TRUE, methods = )hasMethods(f, where, package)getMethods(f, where, table = FALSE)}\arguments{\item{f}{A generic function or the character-string name of one.}\item{where}{Optionally, an environment or position on the search listto look for methods metadata.If \code{where} is missing, \code{findMethods} uses the currenttable of methods in the generic function itself, and\code{hasMethods} looks for metadata anywhere in the search list.}\item{table}{ If \code{TRUE} in a call to \code{getMethods} thereturned value is the table used for dispatch, includinginherited methods discovered to date. Used internally, butsince the default result is the now unused \code{mlist} object,the default will likely be changed at some point.}\item{classes}{If supplied, only methods whose signatures contain atleast one of the supplied classes will be included in the valuereturned.}\item{inherited}{Logical flag; if \code{TRUE}, the table of allmethods, inherited or defined directly, will be used; otherwise,only the methods explicitly defined. Option \code{TRUE} ismeaningful only if \code{where} is missing.}\item{...}{In the call to \code{findMethodSignatures}, any argumentsthat might be given to \code{findMethods}.}\item{target}{Optional flag to \code{findMethodSignatures}; if\code{TRUE}, the signatures used are the target signatures (theclasses for which the method will be selected); if \code{FALSE},they will be the signatures are defined. The difference is onlymeaningful if \code{inherited} is \code{TRUE}.}\item{methods}{In the call to \code{findMethodSignatures}, an optionallist of methods, presumably returned by a previous call to\code{findMethods}. If missing, that function will be call with the\dots arguments.}\item{package}{In a call to \code{hasMethods}, the package name forthe generic function (e.g., \code{"base"} for primitives). Ifmissing this will be inferred either from the \code{"package"}attribute of the function name, if any, or from the package slot ofthe generic function. See \sQuote{Details}.}}\details{The functions obtain a table of the defined methods, either from thegeneric function or from the stored metadata object in the environmentspecified by \code{where}. In a call to \code{getMethods}, the information in the table is convertedas described above to produce the returned value, except with the\code{table} argument.Note that the list returned may contain the primitive function itself,when the generic corresponds to a primitive. (Basically, becauseprimitive functions are abnormal R objects, which cannot currently beextended as method definitions.) Computations that use the returnedlist to derive other information need to take account of thispossibility. See the implementation of \code{findMethodSignatures}for an example.Note that \code{hasMethods}, but not the other functions, can be usedeven if no generic function of this name is currently found. In thiscase \code{package} must either be supplied as an argument or includedas an attribute of \code{f}, since the package name is part of theidentification of the methods tables.These functions should be used in searching for or summarizingmethods, rather than using information about how the metadata formethods is stored.}\seealso{ \code{\link{showMethods}}, \code{\link{MethodsList-class}} }\examples{mm <- findMethods("Ops")findMethodSignatures(methods = mm)}\keyword{programming}\keyword{classes}\keyword{methods}