| tagged literal | since v0.0-1424 | in edn | Edit |
A universally unique identifier (UUID). Randomly generate one with random-uuid.
#uuid "8-4-4-4-12" - numbers represent the number of hex digits#uuid "97bda55b-6175-4c39-9e04-7c0205c709dc" - actual exampleUses the UUID type.
Representing UUIDs with #uuid rather than just a plain string has the following benefits:
To create a UUID from an evaluated expression, use uuid.
#uuid "00000000-0000-0000-0000-000000000000"
;;=> #uuid "00000000-0000-0000-0000-000000000000"
#uuid "97bda55b-6175-4c39-9e04-7c0205c709dc"
;;=> #uuid "97bda55b-6175-4c39-9e04-7c0205c709dc"
#uuid "asdf"
;; clojure.lang.ExceptionInfo: Invalid UUID string: asdf
Get as a string:
(def foo #uuid "97bda55b-6175-4c39-9e04-7c0205c709dc")
(str foo)
;;=> "97bda55b-6175-4c39-9e04-7c0205c709dc"
(defn read-uuid
[form]
(when-not (string? form)
(throw (RuntimeException. "UUID literal expects a string as its representation.")))
(try
(java.util.UUID/fromString form)
(catch Throwable e
(throw (RuntimeException. (.getMessage e))))))(def ^:dynamic *cljs-data-readers*
(merge ;; assumes we can read all data_readers
#?(:clj *data-readers*)
{'queue read-queue
'uuid read-uuid
'inst read-inst
'js read-js}))