Public Vars

Back

defmulti (clj)

(source)

macro

(defmulti name docstring? attr-map? dispatch-fn & options)
Creates a new multimethod with the associated dispatch function. The docstring and attr-map are optional. Options are key-value pairs and may be one of: :default The default dispatch value, defaults to :default :hierarchy The value used for hierarchical dispatch (e.g. ::square is-a ::shape) Hierarchies are type-like relationships that do not depend upon type inheritance. By default Clojure's multimethods dispatch off of a global hierarchy map. However, a hierarchy relationship can be created with the derive function used to augment the root ancestor created with make-hierarchy. Multimethods expect the value of the hierarchy option to be supplied as a reference type e.g. a var (i.e. via the Var-quote dispatch macro #' or the var special form).

Examples

babashka/babashka
(ns babashka.impl.protocols
  (:require [babashka.impl.protocols :as protocols]
            [clojure.core.protocols :as p]
            [clojure.datafy :as d]
            ;; ensure datafy is loaded, we're going to override its
            ;; clojure.lang.Namespace implementation for datafy
            [clojure.reflect]
            [sci.core :as sci :refer [copy-var]]
            [sci.impl.types :as types]
            [sci.impl.vars]))

(defmulti datafy types/type-impl)

;;;; nav
(defmulti nav types/type-impl)
clojure/core.typed
;copied from tools.analyzer.js
(ns clojure.core.typed.analyzer.js.passes.analyze-host-expr
  (:require [clojure.core.typed.analyzer.common :as common]
            [clojure.core.typed.analyzer.common.env :as env]
            [clojure.core.typed.analyzer.common.js :as anajs]))

(defmulti analyze-host-expr
  "Transform :host-interop nodes into :host-call, transform
  :maybe-class or :maybe-host-form nodes resolvable to js vars
  into :js-var nodes"
  {:pass-info {:walk :any :depends #{}}}
  :op)
clojure/core.typed
;copied from clojure.tools.analyzer.passes.constant-lifter
(ns clojure.core.typed.analyzer.common.passes.constant-lifter
  (:require [clojure.core.typed.analyzer.common :as common]
            [clojure.core.typed.analyzer.common.utils :refer [const-val]]))

(defmulti constant-lift
  "If the node represents a collection with no metadata, and every item of that
   collection is a literal, transform the node to an equivalent :const node."
  {:pass-info {:walk :post :depends #{}}}
  :op)
noprompt/meander
(ns multimethods
  (:refer-clojure :exclude [defmethod defmulti])
  (:require
   #?(:clj [clojure.core :as clj] :cljs [cljs.core :as cljs])
   [meander.epsilon :as m]))

(defmacro defmulti [name]
  (swap! cache_ dissoc name)
  `(def ~name (MultiMeanderFn. nil)))

(defmulti test-fn)
bsless/more.async
(ns more.async.dataflow.node
  (:require
   [clojure.spec.alpha :as s]
   [clojure.core.async :as a]
   [more.async :as ma]
   [clojure.data]))

(defmulti -type ::type)

(defmulti -compile (fn [node _env] (get node ::type)))

(defmulti ports ::type)