(rontolisp) docs
← Reference

clojure.edn

Reading EDN, Clojure's data notation, from a string or a stream. clojure.edn is loaded before the program, as in Clojure, so clojure.edn/read-string works without a require. It runs on every backend.

VarBehavior
read-string(read-string s) / (read-string opts s): the first datum of the string; nil for nil, and at the end of input nil (one argument), the :eof option, or an EOF while reading error
read(read) / (read stream) / (read opts stream): one datum from the stream (*in* for none), which is left right after it; at the end of input the :eof option or an error

EDN is data only. The quote is part of a symbol ('a reads the symbol 'a); the syntax-quote, ~, @, #', #(...), #"...", #= and #? are refused with the oracle's messages, and so is an auto-resolved ::keyword. A number starts with a digit or a sign and a digit, so .5 is a symbol. A repeated map key or set member is a Duplicate key error.

Tagged literals

#tag value reads value and calls the function the :readers map holds for the tag symbol, else uses the built-in #inst and #uuid (their values, read like in source), else calls the :default function with the tag and the value. A tag none of them takes is No reader function for tag. A reader may be any function value: a function, a var, a keyword or a map. Like the oracle's, an EDN read asks neither *data-readers* nor *default-data-reader-fn*.

Differences

  • read takes any character stream, also a plain clojure.java.io/reader, where the oracle requires a java.io.PushbackReader.
  • N and M numbers read as plain integers and exact ratios (Syntax).
  • A symbol carries no metadata, so ^:k sym reads the bare symbol.