试图自学一些clojure,正在使用play-clj。我不明白为什么会这样:
(defn add-shape
[x y entities]
(write-state [x y])
(conj entities (o-shape x y)))
虽然这没有:
(defn add-shape
[x y entities]
(conj entities (o-shape x y)
(write-state [x y]))
Exception in thread "LWJGL Application" java.lang.IllegalArgumentException:No implementation of method: :draw-entity! of protocol: #'play-clj.entities/Entity found for class: java.lang.Long
这是两个相关的功能:
(defn x-shape
[x y]
(shape :line
:line (- x 100) (- 600 100 y) (+ x 100) (- (+ 600 100) y)
:line (- x 100) (- (+ 600 100) y) (+ x 100) (- 600 100 y)))
(defn write-state
[arg]
(dosync (alter state conj arg)))