Syntax Clojure—;英镑符号的意义`
在Om下一个快速入门中,他们使用Syntax Clojure—;英镑符号的意义`,syntax,clojure,clojurescript,om,Syntax,Clojure,Clojurescript,Om,在Om下一个快速入门中,他们使用#js和#uuid。这里的英镑符号是什么意思 链接: 片段: #js: (defui Counter static om/IQuery (query [this] [:count]) Object (render [this] (let [{:keys [count]} (om/props this)] (dom/div nil (dom/span nil (str "Count: " count))
#js
和#uuid
。这里的英镑符号是什么意思
链接:
片段:
#js
:
(defui Counter
static om/IQuery
(query [this]
[:count])
Object
(render [this]
(let [{:keys [count]} (om/props this)]
(dom/div nil
(dom/span nil (str "Count: " count))
(dom/button
#js {:onClick
(fn [e] (om/transact! this '[(increment)]))}
"Click me!")))))
#uuid
:
(om/from-history reconciler
#uuid "9e7160a0-89cc-4482-aba1-7b894a1c54b4")
常见于EDN和ClojureScript中,#的这种用法称为标记文字。看看这个例子
user=> (java.util.Date.)
#inst "2014-05-19T19:12:37.925-00:00"
当我们创建一个新日期时,它被表示为一个带标签的文本,或者在本例中是一个带标签的字符串。我们可以使用Clojures读取字符串来读回(或直接使用)
标记的文本告诉读者如何解析文本值。其他常见用途包括#uuid用于生成uuid,而在ClojureScript世界中,标记文字的一个极其常见的用途是#js,它可以用于将ClojureScript数据结构直接转换为JavaScript结构
礼节:
user=> (type #inst "2014-05-19T19:12:37.925-00:00")
java.util.Date
(read-string "#inst \"2014-05-19T19:12:37.925-00:00\"")
#inst "2014-05-19T19:12:37.925-00:00"
user=> (type (read-string "#inst \"2014-05-19T19:12:37.925-00:00\""))
java.util.Date