Search code examples
clojureclojurescript

Does reader/read-string attach metadata to the forms


I've read somewhere that cljs.reader/read-string attaches metadata to the forms that it creates, like the position in the string read.
Is it true? Is it documented somewhere? Thanks.


Solution

  • read-string doesn't add metadata to the returned form:

    => (meta (cljs.reader/read-string "(prn 0)"))
    nil
    

    Your compiled functions/defs/vars will have this type of metadata though:

    => (meta #'my-fn)
    {:ns app.core,
     :name my-fn,
     :file "src/cljs/app/core.cljs",
     :end-column 20,
     :column 1,
     :line 125,
     :end-line 125,
     :arglists ([{:keys [x]}]),
     :doc nil,
     :test nil}