Attempts to read a (ns ...) declaration from rdr, and returns the
unevaluated form. Returns nil if read fails or if a ns declaration
cannot be found. The ns declaration must be the first Clojure form
in the file, except for (comment ...) forms.
(defn read-ns-decl
"Attempts to read a (ns ...) declaration from rdr, and returns the
unevaluated form. Returns nil if read fails or if a ns declaration
cannot be found. The ns declaration must be the first Clojure form
in the file, except for (comment ...) forms."
[^PushbackReader rdr]
(try (let [form (read rdr)]
(cond
(ns-decl? form) form
(comment? form) (recur rdr)
:else nil))
(catch Exception e nil)))
Comments top
No comments for read-ns-decl. Log in to add a comment.