Liking cljdoc? Tell your friends :D

sicmutils.util.def


defgenericclj/s≠macro

clj
(defgeneric name arities docstring? attr-map? & options)
cljs
(defgeneric f arities & options)

Defines a multifn using the provided symbol. Arranges for the multifn to answer the :arity message, reporting either [:exactly a] or [:between a b] according to the arguments given.

  • arities can be either a single or a vector of 2 numbers.

The options allowed differs slightly from defmulti:

  • the first optional argument is a docstring.

  • the second optional argument is a dict of metadata. When you query the defined multimethod with a keyword, it will pass that keyword along as a query to this metadata map. (:arity is always overridden if supplied, and :name defaults to the symbol f.)

Any remaining options are passed along to defmulti.

Defines a multifn using the provided symbol. Arranges for the multifn
to answer the :arity message, reporting either `[:exactly a]` or
`[:between a b]` according to the arguments given.

- `arities` can be either a single or a vector of 2 numbers.

The `options` allowed differs slightly from `defmulti`:

- the first optional argument is a docstring.

- the second optional argument is a dict of metadata. When you query the
defined multimethod with a keyword, it will pass that keyword along as a query
to this metadata map. (`:arity` is always overridden if supplied, and `:name`
defaults to the symbol `f`.)

Any remaining options are passed along to `defmulti`.
sourceraw docstring

import-defclj/smacro

(import-def sym)
(import-def sym var-name)

Given a regular def'd var from another namespace, defined a new var with the same name in the current namespace.

This macro is modeled after potemkin.namespaces/import-def but meant to be usable from Clojurescript. In Clojurescript, it's not possible to:

  • alter the metadata of a var after definition
  • call resolve at macro-time

And therefore not possible to mirror the metadata from one var to another. This simplified version therefore suffices in the cljs case.

Given a regular def'd var from another namespace, defined a new var with the
 same name in the current namespace.

This macro is modeled after `potemkin.namespaces/import-def` but meant to be
usable from Clojurescript. In Clojurescript, it's not possible to:

- alter the metadata of a var after definition
- call `resolve` at macro-time

And therefore not possible to mirror the metadata from one var to another.
This simplified version therefore suffices in the cljs case.
sourceraw docstring

import-varsclj/smacro

(import-vars & imports)

import multiple defs from multiple namespaces. works for vars and fns. not macros.

import-vars has the same syntax as potemkin.namespaces/import-vars:

(import-vars
  [m.n.ns1 a b]
  [x.y.ns2 d e f]) =>
(def a m.n.ns1/a)
(def b m.n.ns1/b)
 ...
(def d m.n.ns2/d)
 ... etc
import multiple defs from multiple namespaces. works for vars and fns. not
macros.

[[import-vars]] has the same syntax as `potemkin.namespaces/import-vars`:

 ```clojure
(import-vars
   [m.n.ns1 a b]
   [x.y.ns2 d e f]) =>
 (def a m.n.ns1/a)
 (def b m.n.ns1/b)
  ...
 (def d m.n.ns2/d)
  ... etc
```
sourceraw docstring

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

× close