Extensions to selectMethod and selectMethodSignature

The calls to selectMethod and selectMethodSignature described in Programming with Data take as arguments the name of a generic function and a signature, that is, a vector of classes corresponding to some of the formal arguments to the function of that name. The functions return respectively a function definition or a signature corresponding to the method the evaluator would select for this function and signature.

For two reasons, one would like also to find the method or the signature corresponding to the current, actual call to the function. First, this is a useful prelude to doing some non-standard generic computations, such as virtual method dispatch. Second, the correct method cannot always be determined by the classes of the argument alone. Suppose, for example, the actual argument x has class "matrix", but the only methods defined correspond to "character" and "numeric". Then the method to be chosen could be either of these or the default, depending on the class of the data contained in the matrix.

In the extension, selectMethod and selectMethodSignature are called with no arguments. They then call internal code in the evaluator to carry out method selection for the actual arguments to the call from which selectMethod or selectMethodSignature was called.

John Chambers<jmc@research.bell-labs.com>
Last modified: Wed Jun 24 15:13:42 EDT 1998