Skip to content

Commit

Permalink
doc data_readers.cljc, closes #568
Browse files Browse the repository at this point in the history
  • Loading branch information
puredanger committed Nov 11, 2021
1 parent df83fbb commit 9e3d853
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions content/reference/reader.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ Clojure's reader supports a superset of https://github.com/edn-format/edn[extens
== Tagged Literals
Tagged literals are Clojure's implementation of edn https://github.com/edn-format/edn#tagged-elements[tagged elements].

When Clojure starts, it searches for files named `data_readers.clj` at the root of the classpath. Each such file must contain a Clojure map of symbols, like this:
When Clojure starts, it searches for files named `data_readers.clj` or `data_readers.cljc` at the root of the classpath. Each such file must contain a Clojure map of symbols, like this:

[source,clojure]
----
Expand All @@ -210,7 +210,9 @@ The key in each pair is a tag that will be recognized by the Clojure reader. The
----
by invoking the Var `#'my.project.foo/bar` on the vector `[1 2 3]`. The data reader function is invoked on the form AFTER it has been read as a normal Clojure data structure by the reader.

Reader tags without namespace qualifiers are reserved for Clojure. Default reader tags are defined in https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/default-data-readers[default-data-readers] but may be overridden in `data_readers.clj` or by rebinding https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/%2Adata-readers%2A[pass:[*data-readers*]]. If no data reader is found for a tag, the function bound in https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/%2Adefault-data-reader-fn%2A[pass:[*default-data-reader-fn*]] will be invoked with the tag and value to produce a value. If pass:[*default-data-reader-fn*] is nil (the default), a RuntimeException will be thrown.
Reader tags without namespace qualifiers are reserved for Clojure. Default reader tags are defined in https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/default-data-readers[default-data-readers] but may be overridden in `data_readers.clj` / `data_readers.cljc` or by rebinding https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/%2Adata-readers%2A[pass:[*data-readers*]]. If no data reader is found for a tag, the function bound in https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/%2Adefault-data-reader-fn%2A[pass:[*default-data-reader-fn*]] will be invoked with the tag and value to produce a value. If pass:[*default-data-reader-fn*] is nil (the default), a RuntimeException will be thrown.

If a `data_readers.cljc` is provided, it is read with the same semantics as any other cljc source file with reader conditionals.

=== Built-in tagged literals

Expand Down

0 comments on commit 9e3d853

Please sign in to comment.