Version: 4.1.4.1

3 Multimethods

 (require (planet "multimethod.ss" ("murphy" "multimethod.plt" 2 1)))

This module provides procedures and syntactic sugar to create multimethods and to attach procedures to them.

Each multimethod is a structure that can act as a procedure accepting any number of arguments and any keyword arguments. When called, it first applies a signature generator to its arguments and keyword arguments, which should produce a single result. This generated signature is then compared with the signatures for registered method implementations to find the one to call. The most specific method that was found is called with the arguments and keyword arguments of the multimethod and an additional first argument that holds a procedure, which can be invoked to call the next less specific method for the same signature or signal an error if there is no further applicable method.

See find-methods for a precise explanation of how methods are looked up.

This module also re-exports the exn:fail:multimethod structure defined in "overloads.ss".