method_explain {S7}R Documentation

Explain method dispatch

Description

method_explain() shows all possible methods that a call to a generic might use, which ones exist, and which one will actually be called.

Note that method dispatch uses a string representation of each class in the class hierarchy. Each class system uses a slightly different convention to avoid ambiguity.

Usage

method_explain(generic, class = NULL, object = NULL)

Arguments

generic

A generic function, i.e. an S7 generic, an external generic, an S3 generic, or an S4 generic.

class, object

Perform introspection either with a class (processed with as_class()) or a concrete object. If generic uses multiple dispatch then both object and class must be a list of classes/objects.

Value

Nothing; this function is called for it's side effects.

Examples

foo1 <- new_class("foo1")
foo2 <- new_class("foo2", foo1)

add <- new_generic("add", c("x", "y"))
method(add, list(foo2, foo1)) <- function(x, y) c(2, 1)
method(add, list(foo1, foo1)) <- function(x, y) c(1, 1)

method_explain(add, list(foo2, foo2))

[Package S7 version 0.1.1 Index]