Utility functions for performing additional operations on multifns and their components not specified in one of the interfaces. These functions are compositions of those methods.
Utility functions for performing additional operations on multifns and their components not specified in one of the interfaces. These functions are compositions of those methods.
(add-aux-method! multifn-var qualifier dispatch-val f)
Destructive version of [[methodical.interface/add-aux-method]]. Operates on a var defining a Methodical multifn.
Destructive version of [[methodical.interface/add-aux-method]]. Operates on a var defining a Methodical multifn.
(add-aux-method-with-unique-key multifn qualifier dispatch-val f unique-key)
Adds an auxiliary method with a unique-key
stored in its metadata. This unique key can later be used to remove the
auxiliary method with remove-aux-method-with-unique-key
. If a method with this key already exists for this
qualifier and dispatch value, replaces the original.
Adds an auxiliary method with a `unique-key` stored in its metadata. This unique key can later be used to remove the auxiliary method with [[remove-aux-method-with-unique-key]]. If a method with this key already exists for this qualifier and dispatch value, replaces the original.
(add-aux-method-with-unique-key! multifn-var
qualifier
dispatch-val
f
unique-key)
Destructive version of add-aux-method-with-unique-key
. Operates on a var defining a Methodical multifn.
Destructive version of [[add-aux-method-with-unique-key]]. Operates on a var defining a Methodical multifn.
(add-preference isa?* prefs x y)
Add a method preference to prefs
for dispatch value x
over y
. Used to implement prefer-method
. isa?*
is
used to determine whether a relationship between x
and y
that precludes this preference already exists; it can
be [[clojure.core/isa?]], perhaps partially bound with a hierarchy, or some other 2-arg predicate function.
Add a method preference to `prefs` for dispatch value `x` over `y`. Used to implement [[prefer-method]]. `isa?*` is used to determine whether a relationship between `x` and `y` that precludes this preference already exists; it can be [[clojure.core/isa?]], perhaps partially bound with a hierarchy, or some other 2-arg predicate function.
(add-primary-method! multifn-var dispatch-val f)
Destructive version of [[add-primary-method]]. Operates on a var defining a Methodical multifn.
Destructive version of [[add-primary-method]]. Operates on a var defining a Methodical multifn.
(alter-var-root+ multifn-var f & args)
Like [[clojure.core/alter-var-root]], but handles vars that are aliases of other vars, e.g. ones that have been imported via Potemkin [[potemkin/import-vars]].
Like [[clojure.core/alter-var-root]], but handles vars that are aliases of other vars, e.g. ones that have been imported via Potemkin [[potemkin/import-vars]].
(applicable-primary-method multifn dispatch-val)
Return the primary method that would be use for dispatch-value
, including ones from ancestor dispatch values or the
default dipsatch value. Method includes ^:dispatch-value
metadata indicating the actual dispatch value for which
the applicable method was defined.
Like primary-method
, the method returned will not have any implicit args (such as next-method
) bound.
Return the primary method that would be use for `dispatch-value`, including ones from ancestor dispatch values or the default dipsatch value. Method includes `^:dispatch-value` metadata indicating the actual dispatch value for which the applicable method was defined. Like [[primary-method]], the method returned will not have any implicit args (such as `next-method`) bound.
(aux-methods multifn)
(aux-methods multifn dispatch-val)
(aux-methods multifn qualifier dispatch-val)
Get all auxiliary methods explicitly specified for dispatch-value
. This function does not include methods that
would otherwise still be applicable (e.g., methods for ancestor dispatch values) -- the methods explicitly defined
for this exact match.
qualifier
-> dispatch value
-> [method]
.qualifier
-> [method]
.methods
.Get all auxiliary methods *explicitly specified* for `dispatch-value`. This function does not include methods that would otherwise still be applicable (e.g., methods for ancestor dispatch values) -- the methods explicitly defined for this exact match. * With 1 arg: methods come back as a map of `qualifier` -> `dispatch value` -> `[method]`. * With 2 args: methods come back as a map of `qualifier` -> `[method]`. * With 3 args: methods come back as sequence of `methods`.
(default-aux-methods multifn)
Get a map of aux qualifier -> methods for the default dispatch value, if any exist.
Get a map of aux qualifier -> methods for the default dispatch value, if any exist.
(default-effective-method multifn)
Return the effective (combined) method for the default dispatch value, if one can be computed.
Return the effective (combined) method for the default dispatch value, if one can be computed.
(default-primary-method multifn)
Get the default primary method associated with this mutlifn
, if one exists.
Get the default primary method associated with this `mutlifn`, if one exists.
(dispatch-fn multifn)
Return a function that can be used to calculate dispatch values of given arg(s).
Return a function that can be used to calculate dispatch values of given arg(s).
(dispatch-value multifn a)
(dispatch-value multifn a b)
(dispatch-value multifn a b c)
(dispatch-value multifn a b c d)
(dispatch-value multifn a b c d e)
(dispatch-value multifn a b c d e f)
(dispatch-value multifn a b c d e f g)
(dispatch-value multifn a b c d e f g & more)
Calculate the dispatch value that multifn
will use given args
.
Calculate the dispatch value that `multifn` will use given `args`.
(effective-dispatch-value multifn dispatch-val)
Return the least-specific dispatch value that would return the same effective method as dispatch-value
. e.g. if
dispatch-value
is Integer
and the effective method is a result of combining a Object
primary method and a
Number
aux method, the effective dispatch value is Number
, since Number
is the most specific thing out of the
primary and aux methods and would get the same effective method as Integer
.
Return the least-specific dispatch value that would return the same effective method as `dispatch-value`. e.g. if `dispatch-value` is `Integer` and the effective method is a result of combining a `Object` primary method and a `Number` aux method, the effective dispatch value is `Number`, since `Number` is the most specific thing out of the primary and aux methods and would get the same effective method as `Integer`.
(effective-primary-method multifn dispatch-val)
Build and effective method equivalent that would be used for this dispatch-value
if it had no applicable auxiliary
methods. Implicit args (such as next-method
) will be bound appropriately. Method has ^:dispatch-value
metadata
for the dispatch value with which the most-specific primary method was defined.
Build and effective method equivalent that would be used for this `dispatch-value` if it had no applicable auxiliary methods. Implicit args (such as `next-method`) will be bound appropriately. Method has `^:dispatch-value` metadata for the dispatch value with which the most-specific primary method was defined.
(fn-vary-meta fun f & args)
Construct a new FnWithMeta with the same underlying function (possibly unwrapped) but with the meta that is the result
of (apply f (meta obj) args)
.
Construct a new FnWithMeta with the same underlying function (possibly unwrapped) but with the meta that is the result of `(apply f (meta obj) args)`.
(fn-with-meta fun mta)
Construct a new FnWithMeta from the provided arguments. Unwrap fun
if it an FnWithMeta too.
Construct a new FnWithMeta from the provided arguments. Unwrap `fun` if it an FnWithMeta too.
(generate-FnWithMeta)
Generate FnWithMeta deftype declaration.
Generate FnWithMeta deftype declaration.
(is-default-effective-method? multifn dispatch-val)
When multifn
is invoked with args that have dispatch-val
, will we end up using the default effective
method (assuming one exists)?
When `multifn` is invoked with args that have `dispatch-val`, will we end up using the default effective method (assuming one exists)?
(is-default-primary-method? multifn dispatch-val)
When multifn
is invoked with args that have dispatch-val
, will we end up using the default primary method (assuming
one exists)?
When `multifn` is invoked with args that have `dispatch-val`, will we end up using the default primary method (assuming one exists)?
(matching-aux-methods multifn dispatch-val)
(matching-aux-methods dispatcher method-table dispatch-val)
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-methods multifn dispatch-val)
(matching-primary-methods dispatcher method-table dispatch-val)
Return a sequence of applicable primary methods for dispatch-value
, sorted from most-specific to least-specific.
Methods include 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 include 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.
(multifn? x)
True if x
is a Methodical multifn (i.e., if it is an instance of StandardMultiFn
).
True if `x` is a Methodical multifn (i.e., if it is an instance of `StandardMultiFn`).
(prefer-method multifn dispatch-val-x dispatch-val-y)
Prefer dispatch-val-x
over dispatch-val-y
for dispatch and method combinations. You can undo this preference
with unprefer-method
.
Prefer `dispatch-val-x` over `dispatch-val-y` for dispatch and method combinations. You can undo this preference with [[unprefer-method]].
(prefer-method! multifn-var dispatch-val-x dispatch-val-y)
Destructive version of prefer-method
. Operates on a var defining a Methodical multifn.
Note that vanilla Clojure [[clojure.core/prefer-method]] is actually itself destructive, so this function is
actually the Methodical equivalent of that function. prefer-method!
is used by Methodical to differentiate the
operation from our nondestructive prefer-method
, which returns a copy of the multifn with an altered dispatch
table.
Destructive version of [[prefer-method]]. Operates on a var defining a Methodical multifn. Note that vanilla Clojure [[clojure.core/prefer-method]] is actually itself destructive, so this function is actually the Methodical equivalent of that function. `prefer-method!` is used by Methodical to differentiate the operation from our nondestructive [[prefer-method]], which returns a copy of the multifn with an altered dispatch table.
(primary-method multifn dispatch-val)
Get the primary method explicitly specified for dispatch-value
. This function does not return methods that would
otherwise still be applicable (e.g., methods for ancestor dispatch values) -- just the methods explicitly defined
for this exact match. (If you want methods that will be used, including those of ancestors dispatch values, you can
use applicable-primary-method
or effective-primary-method
instead.)
Note that the primary method will not have any implicit args (e.g. next-method
) bound the way it normally would
when combined into an effective method; you will need to supply this yourself (or pass nil
for no next-method
).
Get the primary method *explicitly specified* for `dispatch-value`. This function does not return methods that would otherwise still be applicable (e.g., methods for ancestor dispatch values) -- just the methods explicitly defined for this exact match. (If you want methods that will be used, including those of ancestors dispatch values, you can use [[applicable-primary-method]] or [[effective-primary-method]] instead.) Note that the primary method will not have any implicit args (e.g. `next-method`) bound the way it normally would when combined into an effective method; you will need to supply this yourself (or pass `nil` for no `next-method`).
(remove-all-aux-methods multifn)
(remove-all-aux-methods multifn qualifier)
(remove-all-aux-methods multifn qualifier dispatch-val)
With one arg, remove all auxiliary methods for a multifn
. With two args, remove all auxiliary methods for the
given qualifier
(e.g. :before
). With three args, remove all auxiliary methods for a given qualifier
and
dispatch-value
.
With one arg, remove *all* auxiliary methods for a `multifn`. With two args, remove all auxiliary methods for the given `qualifier` (e.g. `:before`). With three args, remove all auxiliary methods for a given `qualifier` and `dispatch-value`.
(remove-all-aux-methods! multifn-var)
(remove-all-aux-methods! multifn-var qualifier)
(remove-all-aux-methods! multifn-var qualifier dispatch-val)
Destructive version of remove-all-aux-methods
. Operates on a var defining a Methodical multifn.
Destructive version of [[remove-all-aux-methods]]. Operates on a var defining a Methodical multifn.
(remove-all-aux-methods-for-dispatch-val multifn dispatch-val)
Remove all auxiliary methods for dispatch-value
for all qualifiers.
Remove all auxiliary methods for `dispatch-value` for *all* qualifiers.
(remove-all-aux-methods-for-dispatch-val! multifn-var dispatch-val)
Destructive version of remove-all-aux-methods-for-dispatch-val
. Operates on a var defining a Methodical multifn.
Destructive version of [[remove-all-aux-methods-for-dispatch-val]]. Operates on a var defining a Methodical multifn.
(remove-all-methods multifn)
Remove all primary and auxiliary methods, including default implementations.
Remove all primary and auxiliary methods, including default implementations.
(remove-all-methods! multifn-var)
Destructive version of remove-all-methods
. Operates on a var defining a Methodical multifn.
Destructive version of [[remove-all-methods]]. Operates on a var defining a Methodical multifn.
(remove-all-preferences multifn)
Return a copy of multifn
with all of its preferences for all dispatch values removed.
To destructively remove all preferences, use remove-all-preferences!
.
Return a copy of `multifn` with all of its preferences for all dispatch values removed. To destructively remove all preferences, use [[remove-all-preferences!]].
(remove-all-preferences! multifn-var)
Destructive version of remove-all-preferences
. Operates on a var defining a Methodical multifn.
Destructive version of [[remove-all-preferences]]. Operates on a var defining a Methodical multifn.
(remove-all-primary-methods multifn)
Remove all primary methods, for all dispatch values (including the default value), for this multifn
or method
table.
Remove all primary methods, for all dispatch values (including the default value), for this `multifn` or method table.
(remove-all-primary-methods! multifn-var)
Destructive version of remove-all-primary-methods
. Operates on a var defining a Methodical multifn.
Destructive version of [[remove-all-primary-methods]]. Operates on a var defining a Methodical multifn.
(remove-aux-method! multifn-var qualifier dispatch-val f)
Destructive version of [[methodical.interface/remove-aux-method]]. Operates on a var defining a Methodical multifn.
Destructive version of [[methodical.interface/remove-aux-method]]. Operates on a var defining a Methodical multifn.
(remove-aux-method-with-unique-key multifn qualifier dispatch-val unique-key)
Remove an auxiliary method that was added by add-aux-method-with-unique-key
, if one exists. Returns multifn
.
Remove an auxiliary method that was added by [[add-aux-method-with-unique-key]], if one exists. Returns `multifn`.
(remove-aux-method-with-unique-key! multifn-var
qualifier
dispatch-val
unique-key)
Destructive version of remove-aux-method-with-unique-key
. Operates on a var defining a Methodical multifn.
Destructive version of [[remove-aux-method-with-unique-key]]. Operates on a var defining a Methodical multifn.
(remove-primary-method! multifn-var dispatch-val)
Destructive version of [[methodical.interface/remove-primary-method]]. Operates on a var defining a Methodical multifn.
Destructive version of [[methodical.interface/remove-primary-method]]. Operates on a var defining a Methodical multifn.
(unprefer-method multifn dispatch-val-x dispatch-val-y)
Return a copy of multifn
with any preferences of dispatch-val-x
over dispatch-val-y
removed. If no such
preference exists, this returns multifn
as-is. Opposite of prefer-method
.
To destructively remove a dispatch value preference, use unprefer-method!
.
Return a copy of `multifn` with any preferences of `dispatch-val-x` over `dispatch-val-y` removed. If no such preference exists, this returns `multifn` as-is. Opposite of [[prefer-method]]. To destructively remove a dispatch value preference, use [[unprefer-method!]].
(unprefer-method! multifn-var dispatch-val-x dispatch-val-y)
Destructive version of unprefer-method
. Operates on a var defining a Methodical multifn.
Destructive version of [[unprefer-method]]. Operates on a var defining a Methodical multifn.
(unwrap-fn-with-meta fun)
If the provided argument is a FnWithMeta object, extract the function it wraps, otherwise return the argument.
If the provided argument is a FnWithMeta object, extract the function it wraps, otherwise return the argument.
(with-prefers! multifn-var new-prefs)
Destructive version of [[methodical.interface/with-prefers]]. Operates on a var defining a Methodical multifn.
Destructive version of [[methodical.interface/with-prefers]]. Operates on a var defining a Methodical multifn.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close