syntax | since v0.0-1853 | in clojure | in edn | Edit |
An unordered set of values. Values must be unique.
#{...}
#{1 2 3}
#{1 2 3}
;;=> #{1 2 3}
Duplicate values will cause an error:
#{1 1 2 3}
;; Error: Duplicate key: 1
(defn- read-set
[rdr _ opts pending-forms]
(let [[start-line start-column] (starting-line-col-info rdr)
;; subtract 1 from start-column so it includes the # in the leading #{
start-column (if start-column (int (dec (int start-column))))
the-set (PersistentHashSet/createWithCheck
(read-delimited :set \} rdr opts pending-forms))
[end-line end-column] (ending-line-col-info rdr)]
(with-meta the-set
(when start-line
(merge
(when-let [file (get-file-name rdr)]
{:file file})
{:line start-line
:column start-column
:end-line end-line
:end-column end-column})))))
(defn- dispatch-macros [ch]
(case ch
\^ read-meta ;deprecated
\' (wrapping-reader 'var)
\( read-fn
\= read-eval
\{ read-set
\< (throwing-reader "Unreadable form")
\" read-regex
\! read-comment
\_ read-discard
\? read-cond
\: read-namespaced-map
\# read-symbolic-value
nil))