by invoking the Var #’my.project.foo/bar about vector [1 2 3] . The data audience function is invoked regarding the kind FOLLOWING it was browse as a normal Clojure facts framework from the reader.
Standard audience tags were identified in default-data-readers but is overridden in data_readers.clj / data_readers.cljc or by rebinding *data-readers*. If no information audience is found for a tag, the big event sure in *default-data-reader-fn* will likely be invoked utilizing the label and value to generate a value. If *default-data-reader-fn* was nil (the default), a RuntimeException would be cast.
If a data_readers.cljc was supplied, it really is see with similar semantics as any kind of cljc source file with audience conditionals.
Integrated tagged literals
Clojure 1.4 introduced the moment and UUID tagged literals. Instants experience the structure #inst “yyyy-mm-ddThh:mm:ss.fff+hh:mm” . NOTE: a number of the aspects of this structure were elective. Start to see the code for facts. The default reader will parse the offered sequence into a java.util.Date automagically. As an example:
Since *data-readers* is actually a powerful var which can be sure, you’ll replace the default viewer with another one. As an example, clojure.instant/read-instant-calendar will parse the literal into a java.util.Calendar , while clojure.instant/read-instant-timestamp will parse it into a java.util.Timestamp :
Default information audience function
If no data audience is found whenever reading a tagged literal, the *default-data-reader-fn* try invoked. You can put your own personal default facts reader function as well as the offered tagged-literal work could be used to develop an object that may store an unhandled literal. The item returned by tagged-literal aids keyword lookup in the :tag and :form :
Clojure 1.7 released a new extension (.cljc) for transportable files that may be packed by multiple Clojure programs. The main mechanism for controlling platform-specific laws would be to separate that signal into a minimal pair of namespaces, following provide platform-specific forms (.clj/.class or .cljs) of the namespaces.
In situations where just isn’t possible to isolate the different elements of the laws, or where in fact the laws is mostly lightweight with best little platform-specific portion, 1.7 additionally released viewer conditionals, which have been recognized only in cljc data and at the standard REPL. Reader conditionals must put meagerly and simply when necessary.
Audience conditionals become a unique viewer dispatch form starting with #? or #? . Both include snap the link now several changing functions and expressions, comparable to cond . Every Clojure platform possess a well-known “platform function” – :clj , :cljs , :cljr . Each symptom in your readers conditional was inspected so as until a feature coordinating the working platform feature is located. Your reader conditional will look over and get back which feature’s phrase. The term for each non-selected branch should be look over but skipped. A well-known :default function will usually accommodate and will be used to render a default. If no limbs accommodate, no kind is read (as though no audience conditional term ended up being existing).
The syntax for #? is strictly the same although appearance is anticipated to go back an assortment that may be spliced in to the encompassing framework, like unquote-splicing in syntax quotation. Usage of viewer conditional splicing at the top degree is not backed and will place an exception. An illustration:
The read and read-string features optionally need a map of alternatives as an initial argument. The existing function set and reader conditional behavior is generally set in the options map by using these techniques and values:
However, remember that the Clojure viewer will always inject the working platform ability :clj as well. For platform-agnostic researching, discover gear.reader.
If the reader are invoked with <:read-cond>, your reader conditional and non-executed branches can be preserved, as information, inside the returned kind. The reader-conditional will be came back as a kind that supporting keyword retrieval for techniques with :form and a :splicing? flag. Browse but skipped marked literals is going to be came back as a type that supporting key phrase retrieval for important factors with :form and :tag points.
The keyed prices inside map become assigned unevaluated to the appropriate sphere in the defrecord. Any defrecord sphere without corresponding entries inside literal map include designated nil since their appreciate. Any added keyed prices into the map literal become included with the resulting defrecord instance.
One of the keys in each pair is a label that’ll be acquiesced by the Clojure reader. The worthiness during the pair could be the fully-qualified name of a Var which is invoked from the viewer to parse the design following label. Eg, because of the data_readers.clj document above, the Clojure viewer would parse this type: