Convenience constructors for various implementations of the different component parts of a Methodical multifn.
Convenience constructors for various implementations of the different component parts of a Methodical multifn.
(+-method-combination)
Executes all applicable primary methods, returnings the sum of the values returned by each method. Same constraints as othe CLOS operator-style method combinations.
Executes *all* applicable primary methods, returnings the sum of the values returned by each method. Same constraints as othe CLOS operator-style method combinations.
(and-method-combination)
Invoke all applicable primary methods, from most-specific to least-specific; reducing the results as if by and
.
Like and
, this method invocation short-circuits if any implementation returns a falsey value. Otherwise, this
method returns the value returned by the last method invoked.
Invoke *all* applicable primary methods, from most-specific to least-specific; reducing the results as if by `and`. Like `and`, this method invocation short-circuits if any implementation returns a falsey value. Otherwise, this method returns the value returned by the last method invoked.
(cached-multifn-impl impl)
(cached-multifn-impl impl cache)
Wrap a MultiFnImpl
in a CachedMultiFnImpl
, which adds caching to calculated effective methods. The cache itself
is swappable with other caches that implement different strategies.
Wrap a `MultiFnImpl` in a `CachedMultiFnImpl`, which adds caching to calculated effective methods. The cache itself is swappable with other caches that implement different strategies.
(clojure-method-combination)
Simple method combination strategy that mimics the way vanilla Clojure multimethods combine methods; that is, to say, not at all. Like vanilla Clojure multimethods, this method combination only supports primary methods.
Simple method combination strategy that mimics the way vanilla Clojure multimethods combine methods; that is, to say, not at all. Like vanilla Clojure multimethods, this method combination only supports primary methods.
(clojure-method-table)
(clojure-method-table m)
Create a new Clojure-style method table. Clojure-style method tables only support primary methods.
Create a new Clojure-style method table. Clojure-style method tables only support primary methods.
(clojure-multifn-impl dispatch-fn
&
{:keys [hierarchy default-value prefers method-table]})
Create a mulitfn impl that largely behaves the same way as a vanilla Clojure multimethod.
Create a mulitfn impl that largely behaves the same way as a vanilla Clojure multimethod.
(clos-method-combination)
Method combination stategy that mimics the standard method combination in the Common Lisp Object System (CLOS).
Supports :before
, :after
, and :around
auxiliary methods. The values returned by :before
and :after
methods
are ignored. Primary methods and around methods get an implicit next-method
arg (see Methodical dox for more on
what this means).
Method combination stategy that mimics the standard method combination in the Common Lisp Object System (CLOS). Supports `:before`, `:after`, and `:around` auxiliary methods. The values returned by `:before` and `:after` methods are ignored. Primary methods and around methods get an implicit `next-method` arg (see Methodical dox for more on what this means).
(clos-multifn-impl dispatch-fn
&
{:keys [hierarchy default-value prefers primary-method-table
aux-method-table]})
Convenience for creating a new multifn instances that for the most part mimics the behavior of CLOS generic functions
using the standard method combination. Supports :before
, :after
, and :around
auxiliary methods, but values of
:before
and :after
methods are ignored, rather than threaded. Primary and :around
methods each get an implicit
next-method
arg.
Convenience for creating a new multifn instances that for the most part mimics the behavior of CLOS generic functions using the standard method combination. Supports `:before`, `:after`, and `:around` auxiliary methods, but values of `:before` and `:after` methods are ignored, rather than threaded. Primary and `:around` methods each get an implicit `next-method` arg.
(concat-method-combination)
Like the seq-method-combination
, but concatenates all the results together.
seq-method-combination : map :: concat-method-combination : mapcat
Like the `seq-method-combination`, but concatenates all the results together. seq-method-combination : map :: concat-method-combination : mapcat
(default-multifn dispatch-fn & {:keys [hierarchy default-value prefers]})
Create a new Methodical multifn using the default impl.
Create a new Methodical multifn using the default impl.
(default-multifn-impl dispatch-fn & {:keys [hierarchy default-value prefers]})
Create a basic multifn impl using default choices for method combination, dispatcher, and method table.
Create a basic multifn impl using default choices for method combination, dispatcher, and method table.
(do-method-combination)
Based on the CLOS progn
method combination. Sequentially executes all applicable primary methods, presumably for
side-effects, in order from most-specific to least-specific; returns the value returned by the least-specific
method. do
method combinations support :around
auxiliary methods, but not :before
or :after
methods.
Based on the CLOS `progn` method combination. Sequentially executes *all* applicable primary methods, presumably for side-effects, in order from most-specific to least-specific; returns the value returned by the least-specific method. `do` method combinations support `:around` auxiliary methods, but not `:before` or `:after` methods.
(everything-dispatcher &
{:keys [hierarchy prefers]
:or {hierarchy (var clojure.core/global-hierarchy)
prefers {}}})
A Dispatcher that always considers all primary and auxiliary methods to be matches; does not calculate dispatch
values for arguments when invoking. Dispatch values are still used to sort methods from most- to least- specific,
using hierarchy
and map of prefers
.
A Dispatcher that always considers *all* primary and auxiliary methods to be matches; does not calculate dispatch values for arguments when invoking. Dispatch values are still used to sort methods from most- to least- specific, using `hierarchy` and map of `prefers`.
(max-method-combination)
Executes all applicable primary methods, and returns the maximum value returned by any one implemenation. Same constraints as othe CLOS operator-style method combinations.
Executes *all* applicable primary methods, and returns the maximum value returned by any one implemenation. Same constraints as othe CLOS operator-style method combinations.
(min-method-combination)
Based on the CLOS method combination of the same name. Executes all applicable primary methods, returning the
minimum value returned by any implementation. Like do
method combinations, min
supports :around
auxiliary
methods, but not :before
or :after
.
Based on the CLOS method combination of the same name. Executes *all* applicable primary methods, returning the minimum value returned by any implementation. Like `do` method combinations, `min` supports `:around` auxiliary methods, but not `:before` or `:after`.
(multi-default-dispatcher dispatch-fn
&
{:keys [hierarchy default-value prefers]
:or {hierarchy (var clojure.core/global-hierarchy)
default-value :default
prefers {}}})
Like the standard dispatcher, with one big improvement: when dispatching on multiple values, it supports default
methods that specialize on some args and use the default for others. (e.g. [String :default]
)
Like the standard dispatcher, with one big improvement: when dispatching on multiple values, it supports default methods that specialize on some args and use the default for others. (e.g. `[String :default]`)
(multifn impl)
(multifn impl mta)
(multifn impl mta cache)
Create a new cached Methodical multifn using impl
as the multifn implementation.
Create a new *cached* Methodical multifn using `impl` as the multifn implementation.
(or-method-combination)
Like the and
combination, but combines result as if by or
; short-circuits after the first matching primary method
returns a truthy value.
Like the `and` combination, but combines result as if by `or`; short-circuits after the first matching primary method returns a truthy value.
(seq-method-combination)
Executes all applicable primary methods, from most-specific to least-specific; returns a sequence of results from
the method invocations. Inspired by CLOS nconc
and append
method combinations, but unlike those, this
combination returns a completely lazy sequence. Like other CLOS-operator-inspired method combinations, this
combination currently supports :around
methods, but not :before
or :after
methods.
Executes *all* applicable primary methods, from most-specific to least-specific; returns a sequence of results from the method invocations. Inspired by CLOS `nconc` and `append` method combinations, but unlike those, this combination returns a completely lazy sequence. Like other CLOS-operator-inspired method combinations, this combination currently supports `:around` methods, but not `:before` or `:after` methods.
(simple-cache)
(simple-cache m)
Create a basic dumb cache. The simple cache stores
Create a basic dumb cache. The simple cache stores
(standard-dispatcher dispatch-fn
&
{:keys [hierarchy default-value prefers]
:or {hierarchy (var clojure.core/global-hierarchy)
default-value :default
prefers {}}})
Create a stanadrd Methodical multifn dispatcher. The standard dispatcher replicates the way vanilla Clojure
multimethods handle multimethod dispatch, with support for a custom hierarchy
, default-value
and map of
prefers
.
Create a stanadrd Methodical multifn dispatcher. The standard dispatcher replicates the way vanilla Clojure multimethods handle multimethod dispatch, with support for a custom `hierarchy`, `default-value` and map of `prefers`.
(standard-method-table)
(standard-method-table primary aux)
Create a new standard method table that supports both primary and auxiliary methods.
Create a new standard method table that supports both primary and auxiliary methods.
(standard-multifn-impl combo dispatcher method-table)
Create a basic multifn impl using method combination combo
, dispatcher dispatcher
, and method-table
.
Create a basic multifn impl using method combination `combo`, dispatcher `dispatcher`, and `method-table`.
(thread-first-method-combination)
Similar the the standard CLOS-style method combination, but threads the result of each :before
and :after
auxiliary methods, as well as the primary method, as the first arg of subsequent method invocations.
Similar the the standard CLOS-style method combination, but threads the result of each `:before` and `:after` auxiliary methods, as well as the primary method, as the *first* arg of subsequent method invocations.
(thread-last-method-combination)
Similar the the standard CLOS-style method combination, but threads the result of each :before
and :after
auxiliary methods, as well as the primary method, as the last arg of subsequent method invocations.
Similar the the standard CLOS-style method combination, but threads the result of each `:before` and `:after` auxiliary methods, as well as the primary method, as the *last* arg of subsequent method invocations.
(uncached-multifn impl)
(uncached-multifn impl mta)
Create a new Methodical multifn using impl
as the multifn implementation; impl
itself should implement
MultiFnImpl
. DOES NOT CACHE EFFECTIVE METHODS -- use multifn
instead, unless you like slow dispatch times.
Create a new Methodical multifn using `impl` as the multifn implementation; `impl` itself should implement `MultiFnImpl`. DOES NOT CACHE EFFECTIVE METHODS -- use `multifn` instead, unless you like slow dispatch times.
(watching-cache cache references)
Wrap cache
in a WatchingCache
, which clears the cache whenever one of the watched references
(such as vars or
atoms) changes. Intended primarily for use with 'permanent' MultiFns, such as those created with defmulti
; this is
rarely needed or wanted for transient multifns.
Wrap `cache` in a `WatchingCache`, which clears the cache whenever one of the watched `references` (such as vars or atoms) changes. Intended primarily for use with 'permanent' MultiFns, such as those created with `defmulti`; this is rarely needed or wanted for transient multifns.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close