Combined interface to everything in Methodical you'd normally want to use.
Combined interface to everything in Methodical you'd normally want to use.
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.
A basic, dumb cache. SimpleCache
stores cached methods in a simple map of dispatch-value -> effective method; it
offers no facilities to deduplicate identical methods for the same dispatch value. This behaves similarly to the
caching mechanism in vanilla Clojure.
A basic, dumb cache. `SimpleCache` stores cached methods in a simple map of dispatch-value -> effective method; it offers no facilities to deduplicate identical methods for the same dispatch value. This behaves similarly to the caching mechanism in vanilla Clojure.
No vars found in this namespace.
A Cache
implementation that wraps any other cache, watching one or more references (such as an
atom or var), calling clear-cache!
whenever one of those references changes.
WatchingCaches can be created by calling add-watches
on another cache. add-watches
is composable, meaning you
can thread multiple calls to it to build a cache that watches the entire world go by. You could, for example, use
this to build a multifn that supports a dynamic set of hierarchies, letting you add more as you go. The world's your
oyster!
WatchingCaches' watch functions weakly reference their caches, meaning they do not prevent garbage collection of
potentially large method maps; they also automatically clear out their watches when they are garbage collected and
finalized (which, of course, may actually be never -- but worst-case is that some unneeded calls to clear-cache!
get made).
A `Cache` implementation that wraps any other cache, watching one or more references (such as an atom or var), calling `clear-cache!` whenever one of those references changes. WatchingCaches can be created by calling `add-watches` on another cache. `add-watches` is composable, meaning you can thread multiple calls to it to build a cache that watches the entire world go by. You could, for example, use this to build a multifn that supports a dynamic set of hierarchies, letting you add more as you go. The world's your oyster! WatchingCaches' watch functions weakly reference their caches, meaning they do not prevent garbage collection of potentially large method maps; they also automatically clear out their watches when they are garbage collected and finalized (which, of course, may actually be never -- but worst-case is that some unneeded calls to `clear-cache!` get made).
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.
No vars found in this namespace.
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).
No vars found in this namespace.
Utility functions for implementing method combinations.
Utility functions for implementing method combinations.
Method combinations strategies based on the non-default method combination types in CLOS. All non-default method combinations follow the same basic pattern:
(operator (primary-method-1 args) (primary-method-2 args) (primary-method-3 args)))
(Example from "Object-Oriented Programming in Common Lisp", Keene 1988.)
The non-default method combinations each support primary methods and :around
methods, but not :before
or
:after
. Unlike the standard combination, primary methods do not support call-next-method
(next-method
in
Methodical).
There are 9 built-in method combinations types in CLOS, excluding standard
: progn
, append
, list
, nconc
,
and
, or
, max
, min
, and +
. These are mostly the same in the implementation below, with the following
exceptions:
The progn
combo is instead named do
, which you probably could have guessed.
list
has been replaced by seq
, which returns a lazy sequence -- a very Clojurey improvement.
Both nconc
and append
concatenate lists, but nconc
does it destructively; append
copies all arguments
except the last. The Clojure equivalent of either is concat
which is what I have named the method combination
below. We actually do one better than CLOS and return a lazy sequence, but lazy-cat
seemed like a cumbersome name
for the combo.
One last difference: unlike CLOS operator method combinations, primary method implementations are not qualfied by their operator.
;; CLOS (defmethod total-electric-supply + ((city city)) ...)
;; Methodical (defmethod total-electric-supply :city [city] ...)
Method combinations strategies based on the non-default method combination types in CLOS. All non-default method combinations follow the same basic pattern: (operator (primary-method-1 args) (primary-method-2 args) (primary-method-3 args))) (Example from "Object-Oriented Programming in Common Lisp", Keene 1988.) The non-default method combinations each support primary methods and `:around` methods, but not `:before` or `:after`. Unlike the standard combination, primary methods do not support `call-next-method` (`next-method` in Methodical). There are 9 built-in method combinations types in CLOS, excluding `standard`: `progn`, `append`, `list`, `nconc`, `and`, `or`, `max`, `min`, and `+`. These are mostly the same in the implementation below, with the following exceptions: * The `progn` combo is instead named `do`, which you probably could have guessed. * `list` has been replaced by `seq`, which returns a lazy sequence -- a very Clojurey improvement. * Both `nconc` and `append` concatenate lists, but `nconc` does it destructively; `append` copies all arguments except the last. The Clojure equivalent of either is `concat` which is what I have named the method combination below. We actually do one better than CLOS and return a lazy sequence, but `lazy-cat` seemed like a cumbersome name for the combo. One last difference: unlike CLOS operator method combinations, primary method implementations *are not* qualfied by their operator. ;; CLOS (defmethod total-electric-supply + ((city city)) ...) ;; Methodical (defmethod total-electric-supply :city [city] ...)
Utility functions for implementing Dispatchers.
Utility functions for implementing Dispatchers.
No vars found in this namespace.
A single-hierarchy dispatcher similar to 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]
A single-hierarchy dispatcher similar to 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]`
A single-hierarchy dispatcher that behaves similarly to the way multimethod dispatch is done by vanilla Clojure multimethods, but with added support for auxiliary methods.
A single-hierarchy dispatcher that behaves similarly to the way multimethod dispatch is done by vanilla Clojure multimethods, but with added support for auxiliary methods.
No vars found in this namespace.
No vars found in this namespace.
No vars found in this namespace.
Standard Methodical MultiFn impl, which
Standard Methodical MultiFn impl, which
Methodical versions of vanilla Clojure defmulti
and defmethod
macros.
Methodical versions of vanilla Clojure `defmulti` and `defmethod` macros.
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.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close