Liking cljdoc? Tell your friends :D

methodical.interface


Cachecljprotocol

A cache, if present, implements a caching strategy for effective methods, so that they need not be recomputed on every invocation.

A *cache*, if present, implements a caching strategy for effective methods, so that they need not be recomputed on
every invocation.

cache-method!clj

(cache-method! cache dispatch-value method)

Cache the effective method for dispatch-value in this cache.

Cache the effective method for `dispatch-value` in this cache.

cached-methodclj

(cached-method cache dispatch-value)

Return cached effective method for dispatch-value, if it exists in the cache.

Return cached effective method for `dispatch-value`, if it exists in the cache.

clear-cache!clj

(clear-cache! cache)

Empty the contents of the cache in-place.

Empty the contents of the cache in-place.

empty-copyclj

(empty-copy cache)

Return an empty copy of the same type as this cache, e.g. for use when copying a multifn.

Return an empty copy of the same type as this cache, e.g. for use when copying a multifn.
sourceraw docstring

Dispatchercljprotocol

A dispatcher decides which dispatch value should be used for a given set of arguments, which primary and auxiliary methods from the method table are applicable for that dispatch value, and the order those methods should be applied in -- which methods are most specific, and which are the least specific (e.g., String is more-specific than Object).

A *dispatcher* decides which dispatch value should be used for a given set of arguments, which primary and
auxiliary methods from the *method table* are applicable for that dispatch value, and the order those methods should
be applied in -- which methods are most specific, and which are the least specific (e.g., `String` is more-specific
than `Object`).

default-dispatch-valueclj

(default-dispatch-value dispatcher)

Default dispatch value to use if no other dispatch value matches.

Default dispatch value to use if no other dispatch value matches.

dispatch-valueclj

(dispatch-value dispatcher)
(dispatch-value dispatcher a)
(dispatch-value dispatcher a b)
(dispatch-value dispatcher a b c)
(dispatch-value dispatcher a b c d)
(dispatch-value dispatcher a b c d more)

Return an appropriate dispatch value for args passed to a multimethod. (This method is equivalent in purpose to the dispatch function of vanilla Clojure multimethods.)

Return an appropriate dispatch value for args passed to a multimethod. (This method is equivalent in purpose to
the dispatch function of vanilla Clojure multimethods.)

dominates?clj

(dominates? dispatcher dispatch-val-x dispatch-val-y)

Is dispatch-val-x considered more specific than dispatch-val-y?

Is `dispatch-val-x` considered more specific than `dispatch-val-y`?

matching-aux-methodsclj

(matching-aux-methods dispatcher method-table dispatch-value)

Return a map of aux method qualifier -> sequence of applicable methods for dispatch-value, sorted from most-specific to least-specific. Methods should have the ^:dispatch-value with which they were defined as metadata.

Return a map of aux method qualifier -> sequence of applicable methods for `dispatch-value`, sorted from
most-specific to least-specific. Methods should have the `^:dispatch-value` with which they were defined as
metadata.

matching-primary-methodsclj

(matching-primary-methods dispatcher method-table dispatch-value)

Return a sequence of applicable primary methods for dispatch-value, sorted from most-specific to least-specific. Methods should have the ^:dispatch-value with which they were defined as metadata. The standard dispatcher also checks to make sure methods in the sequence are not ambiguously specific, replacing ambiguous methods with ones that will throw an Exception when invoked.

Return a sequence of applicable primary methods for `dispatch-value`, sorted from most-specific to
least-specific. Methods should have the `^:dispatch-value` with which they were defined as metadata. The standard
dispatcher also checks to make sure methods in the sequence are not ambiguously specific, replacing ambiguous
methods with ones that will throw an Exception when invoked.

prefer-methodclj

(prefer-method dispatcher dispatch-val-x dispatch-val-y)

Prefer dispatch-val-x over dispatch-val-y for dispatch and method combinations.

Prefer `dispatch-val-x` over `dispatch-val-y` for dispatch and method combinations.

prefersclj

(prefers dispatcher)

Return a map of preferred dispatch value -> set of other dispatch values.

Return a map of preferred dispatch value -> set of other dispatch values.
sourceraw docstring

MethodCombinationcljprotocol

A method combination defines the way applicable primary and auxiliary methods are combined into a single effective method. Method combinations also specify which auxiliary method qualifiers (e.g. :before or :around) are allowed, and how defmethod macro forms using those qualifiers are expanded (e.g., whether they get an implicit next-method arg).

A *method combination* defines the way applicable primary and auxiliary methods are combined into a single *effective
method*. Method combinations also specify which auxiliary method *qualifiers* (e.g. `:before` or `:around`) are
allowed, and how `defmethod` macro forms using those qualifiers are expanded (e.g., whether they get an implicit
`next-method` arg).

allowed-qualifiersclj

(allowed-qualifiers method-combination)

The set containg all qualifiers supported by this method combination. nil in the set means the method combination supports primary methods (because primary methods have no qualifier); all other values refer to auxiliary methods with that qualifer, e.g. :before, :after, or :around.

(allowed-qualifiers (clojure-method-combination)) ;-> #{nil} (allowed-qualifiers (clos-method-combination)) ;-> #{nil :before :after :around} (allowed-qualifiers (doseq-method-combination)) ;-> #{:doseq}

The set containg all qualifiers supported by this method combination. `nil` in the set means the method
combination supports primary methods (because primary methods have no qualifier); all other values refer to
auxiliary methods with that qualifer, e.g. `:before`, `:after`, or `:around`.

(allowed-qualifiers (clojure-method-combination)) ;-> #{nil}
(allowed-qualifiers (clos-method-combination))    ;-> #{nil :before :after :around}
(allowed-qualifiers (doseq-method-combination))   ;-> #{:doseq}

combine-methodsclj

(combine-methods method-combination primary-methods aux-methods)

Combine a sequence of matching primary-methods with aux-methods (a map of qualifier -> sequence of methods) into a single effective method. Method includes effective ^:dispatch-value metadata.

Combine a sequence of matching `primary-methods` with `aux-methods` (a map of qualifier -> sequence of methods)
into a single effective method. Method includes effective `^:dispatch-value` metadata.

transform-fn-tailclj

(transform-fn-tail method-combination qualifier fn-tail)

Make appropriate transformations to the fn-tail of a defmethod macro expansion for a primary method (qualifier will be nil) or an auxiliary method. You can use this method to add implicit args like next-method to the body of a defmethod macro. (Because this method is invoked during macroexpansion, it should return a Clojure form.)

Make appropriate transformations to the `fn-tail` of a `defmethod` macro expansion for a primary
method (qualifier will be `nil`) or an auxiliary method. You can use this method to add implicit args like
`next-method` to the body of a `defmethod` macro. (Because this method is invoked during macroexpansion, it should
return a Clojure form.)
sourceraw docstring

MethodTablecljprotocol

A method table stores primary and auxiliary methods, and returns them when asked. The default implementation, standard-method-table, uses simple Clojure immutable maps.

A *method table* stores primary and auxiliary methods, and returns them when asked. The default implementation,
`standard-method-table`, uses simple Clojure immutable maps.

add-aux-methodclj

(add-aux-method method-table qualifier dispatch-value f)

Add an auxiliary method implementation for qualifer (e.g. :before) and dispatch-value. Unlike primary methods, auxiliary methods are not limited to one method per dispatch value; thus this method does not remove existing methods for this dispatch value. existing

Add an auxiliary method implementation for `qualifer` (e.g. `:before`) and `dispatch-value`. Unlike primary
methods, auxiliary methods are not limited to one method per dispatch value; thus this method does not remove
existing methods for this dispatch value. existing 

add-primary-methodclj

(add-primary-method method-table dispatch-value f)

Set the primary method implementation for dispatch-value, replacing it if it already exists.

Set the primary method implementation for `dispatch-value`, replacing it if it already exists.

aux-methodsclj

(aux-methods method-table)

Get a qualifier -> dispatch-value -> [fn] map of all auxiliary methods associated with this method table.

Get a `qualifier -> dispatch-value -> [fn]` map of all auxiliary methods associated with this method table.

primary-methodsclj

(primary-methods method-table)

Get a dispatch-value -> fn map of all primary methods assoicated with this method table.

Get a `dispatch-value -> fn` map of all primary methods assoicated with this method table.

remove-aux-methodclj

(remove-aux-method method-table qualifier dispatch-val method)

Remove an auxiliary method from a method table. Because multiple auxiliary methods are allowed for the same dispatch value, existing implementations of MethodTable are currently only able to remove exact matches -- for functions, this usually means identical objects.

In the future, I hope to fix this by storing unique indentifiers in the metadata of methods in the map.

Remove an auxiliary method from a method table. Because multiple auxiliary methods are allowed for the same
dispatch value, existing implementations of `MethodTable` are currently only able to remove exact matches -- for
functions, this usually means identical objects.

In the future, I hope to fix this by storing unique indentifiers in the metadata of methods in the map.

remove-primary-methodclj

(remove-primary-method method-table dispatch-value)

Remove the primary method for dispatch-value.

Remove the primary method for `dispatch-value`.
sourceraw docstring

MultiFnImplcljprotocol

Protocol for a complete Methodical multimethod, excluding the optional cache (multimethods with caching wrap a MultiFnImpl). Methodical multimethods are divided into four components: a method combination, which implements methodical.interface/MethodCombination; a method table, which implements methodical.interface/MethodTable; a dispatcher, which implements methodical.interface/Dispatcher; and, optionally, a cache, which implements methodical.interface/Cache. The methods in this protocol are used to access or modify the various constituent parts of a methodical multimethod, and to use them in concert to create an effective method.

Protocol for a complete Methodical multimethod, excluding the optional cache (multimethods with caching wrap a
`MultiFnImpl`). Methodical multimethods are divided into four components: a *method combination*, which
implements [[methodical.interface/MethodCombination]]; a *method table*, which
implements [[methodical.interface/MethodTable]]; a *dispatcher*, which
implements [[methodical.interface/Dispatcher]]; and, optionally, a *cache*, which
implements [[methodical.interface/Cache]]. The methods in *this* protocol are used to access or modify the various
constituent parts of a methodical multimethod, and to use them in concert to create an *effective method*.

dispatcherclj

(dispatcher multifn)

Get the dispatcher associated with this multifn.

Get the dispatcher associated with this multifn.

effective-methodclj

(effective-method multifn dispatch-value)

Return the effective method for dispatch-value. The effective method is a combined primary method and applicable auxiliary methods that can be called like a normal function. effective-method is similar in purpose to get-method in vanilla Clojure multimethods; a different name is used here because I felt get-method would be ambiguous with regards to whether it returns only a primary method or a combined effective method.

Return the effective method for `dispatch-value`. The effective method is a combined primary method and
applicable auxiliary methods that can be called like a normal function. `effective-method` is similar in purpose
to `get-method` in vanilla Clojure multimethods; a different name is used here because I felt `get-method` would
be ambiguous with regards to whether it returns only a primary method or a combined effective method.

method-combinationclj

(method-combination multifn)

Get the method combination associated with this multifn.

Get the method combination associated with this multifn.

method-tableclj

(method-table multifn)

Get the method table associated with this multifn.

Get the method table associated with this multifn.

with-dispatcherclj

(with-dispatcher multifn new-dispatcher)

Return a copy of this multifn using new-dispatcher as its dispatcher.

Return a copy of this multifn using `new-dispatcher` as its dispatcher.

with-method-tableclj

(with-method-table multifn new-method-table)

Return a copy of this multifn using new-method-table as its method table.

Return a copy of this multifn using `new-method-table` as its method table.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close