clojure.datafy
Values turned into data, and navigation from data back to what it stands for, over the
protocols of clojure.core.protocols. Require clojure.datafy to use it;
clojure.core.protocols is loaded before the program, as in Clojure, so a qualified name
reaches it without a require. Both are Clojure source written for rontolisp from the
documented behavior of Clojure's namespaces, and run the same on every backend.
| Var | Behavior |
|---|---|
clojure.datafy/datafy | (datafy x): x as data through Datafiable; when that answers a new collection, its metadata holds x as :clojure.datafy/obj and the symbol of its class as :clojure.datafy/class. An exception answers Throwable->map's map; an atom, ref or agent [value] with its metadata |
clojure.datafy/nav | (nav coll k v): what v, found under k in coll, stands for, through Navigable; v itself unless extended |
clojure.core.protocols/Datafiable, datafy | The protocol behind datafy: nil and every other value answer themselves; extendable through metadata |
clojure.core.protocols/Navigable, nav | The protocol behind nav, extendable through metadata |
clojure.core.protocols/CollReduce, coll-reduce | (coll-reduce coll f) / (coll-reduce coll f val): reduce of a collection by the collection itself. A record, deftype or reify extending it reduces through it under reduce, into, transduce and the other verbs built on reduce (reduce) |
clojure.core.protocols/IKVReduce, kv-reduce | (kv-reduce amap f init): reduce-kv of a collection by the collection itself, which reduce-kv, update-vals and update-keys reach for a record, deftype or reify extending it |
clojure.core.protocols/InternalReduce, internal-reduce | (internal-reduce s f start): reduce of a seq as a protocol |
A protocol declared extendable through metadata finds a method in the value's metadata under the method's qualified symbol, ahead of the extensions:
A type reduces through its own CollReduce or IKVReduce row:
Differences
iterator-reduce!is not built in (it reduces ajava.util.Iterator); naming it is an error that says so.reduceandreduce-kvconsultCollReduceandIKVReducefor a record, deftype orreifyonly: an extension of either protocol tonil,Objector a core kind (aString, a map) is reached by callingcoll-reduceorkv-reduceitself, while Clojure'sreducetakes it for a collection that does not reduce itself (a string, a map).reducedoes not consultInternalReduce.- A namespace or class datafies to itself (Clojure answers a map of its members). An exception's map has no frames (Throwable->map).