Liking cljdoc? Tell your friends :D

dvlopt.fdat

Serialization and deserialization utilities for IMetas such as function and infinite sequences, amongst other things.

See README for the big picture.

Serialization and deserialization utilities for IMetas such as function and infinite sequences,
amongst other things.

See README for the big picture.
raw docstring

?cljmacro

(? [f-sym & args :as call])
(? k [f-sym & args :as call])

Captures how an imeta is created so that it can be turned into a memento, thus become serializable.

Analyses the given form which is a function call, extracting the first item as a key, the rest as args, and puts this information in the metadata after the form is evaled.

(? (range))

(= (meta *1)
   {::key 'clojure.core/range})


(? (my-f 1 2 3))

(= (meta *1)
   {::key  'my.namespace/my-f
    ::args [1 2 3]})     

Providing a key explicitly:

(? ::my-key
   (my-f 1 2 3))

The function symbol, if it is not already, gets qualified either to 'clojure.core if it is part of it, or to the current namespace. Thus, function calls to other namespaces should always be qualified. This behavior mathes what can be achieved in CLJS.

When supplied explicitely, a key is used as is. A key must be a qualified symbol or qualified keyword.

Uses snapshot under the hood.

README documents how this capturing can be turned on a per-namespace basis.

Captures how an imeta is created so that it can be turned into a [[memento]], thus become serializable.

Analyses the given form which is a function call, extracting the first item as a key, the rest as args,
and puts this information in the metadata after the form is evaled.

```clojure
(? (range))

(= (meta *1)
   {::key 'clojure.core/range})


(? (my-f 1 2 3))

(= (meta *1)
   {::key  'my.namespace/my-f
    ::args [1 2 3]})     
```

Providing a key explicitly:

```clojure
(? ::my-key
   (my-f 1 2 3))
```

The function symbol, if it is not already, gets qualified either to 'clojure.core if it is part of it,
or to the current namespace. Thus, function calls to other namespaces should always be qualified.
This behavior mathes what can be achieved in CLJS.

When supplied explicitely, a key is used as is. A key must be a qualified symbol or qualified keyword.

Uses [[snapshot]] under the hood.

README documents how this capturing can be turned on a per-namespace basis.
sourceraw docstring

mementoclj/s

(memento x)

If x has at least a ::key in it metadata, returns a Memento.

Nil otherwise. Safe to call on any value.

Serializers typically deal in concrete types. Here is one.

A Memento simply stores metadata under :snapshot. Those metadata can then be given back to the serializer as a simple map.

See also recall.

If `x` has at least a ::key in it metadata, returns a Memento.

Nil otherwise. Safe to call on any value.

Serializers typically deal in concrete types. Here is one.

A Memento simply stores metadata under `:snapshot`. Those metadata can then
be given back to the serializer as a simple map.

See also [[recall]].
sourceraw docstring

Mementocljs

source

ns-symclj

(ns-sym sym)

Shows how an unqualified symbol gets qualified in the context of ?.

CLJ only.

Shows how an unqualified symbol gets qualified in the context of [[?]].

CLJ only.
sourceraw docstring

recallclj/s

(recall metadata)
(recall regsitry metadata)

"Recall how an IMeta was was using its former metadata."

Given metadata containing a ::key and (if needed) ::args, rebuilds an IMeta by calling the appropriate function from the registry (global if not provided).

Used as a last step in deserialization. Is NOT recursive, meaning that if an arg need to be recalled, it will not. This is actually what is needed as deserializers work that way, in a depth-first manner.

See also memento.

"Recall how an IMeta was was using its former metadata."

Given `metadata` containing a ::key and (if needed) ::args, rebuilds an IMeta by calling
the appropriate function from the `registry` (global if not provided).

Used as a last step in deserialization. Is NOT recursive, meaning that if an arg need to be
recalled, it will not. This is actually what is needed as deserializers work that way, in
a depth-first manner.

See also [[memento]].
sourceraw docstring

registerclj/s

(register k->f)
(register registry k->f)

Adds or removes functions for keys.

k->f is a map where k is an arbitrary key (a qualified symbol or qualified keyword) and f specifies a function such as:

{'some.ns/my-fn-1 my-fn-1      ;; Args can by variadic
 'some.ns/my-fn-2 [2 my-fn-2]  ;; Optimized destructuring for 2 args
 'some.ns/my-fn-3 nil          ;; Removes that key
 }

Providing the number of arguments will result in faster function application by using destructuring instead of apply. Arities 0 to 8 can be optimized that way. Beyond, reverts to using apply. Providing :no-apply instead of a number means the function will not be called, simply returned in exchange of args.

Adds or removes functions for keys.

`k->f` is a map where `k` is an arbitrary key (a qualified symbol or qualified keyword) and `f` specifies
a function such as:

```clojure
{'some.ns/my-fn-1 my-fn-1      ;; Args can by variadic
 'some.ns/my-fn-2 [2 my-fn-2]  ;; Optimized destructuring for 2 args
 'some.ns/my-fn-3 nil          ;; Removes that key
 }
```

Providing the number of arguments will result in faster function application by using destructuring instead
of `apply`. Arities 0 to 8 can be optimized that way. Beyond, reverts to using `apply`. Providing `:no-apply`
instead of a number means the function will not be called, simply returned in exchange of args.
sourceraw docstring

registryclj/s

(registry)
(registry k)

Access to the global registry.

Access to the global registry.
sourceraw docstring

snapshotclj/s

(snapshot imeta k)
(snapshot imeta k args)

Manual annotations of how imeta can be recalled using k and args.

Simply puts that information in its metadata.

Typically, the ? macro is prefered as it does this automatically.

Manual annotations of how `imeta` can be [[recall]]ed using `k` and `args`.

Simply puts that information in its metadata.

Typically, the [[?]] macro is prefered as it does this automatically.
sourceraw docstring

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

× close