Here s part of an overloaded protocol definition:
(defprotocol ClientProtocol
(create-edge
[this outV label inV]
[this outV label inV data])
And here s part of its implementation:
(ns bulbs.neo4jserver.client
(:use [bulbs.base.client :only [ClientProtocol]]))
(deftype Neo4jClient [ns config]
ClientProtocol
(create-edge
[this outV label inV data]
(let [inV-uri (utils/normalize-uri (build-path neo4j-uri vertex-path inV))
path (build-path vertex-path, outV, "relationships")
params {:to inV-uri, :type label, :data (first data)}]
(post config path params)))
(create-edge
[this outV label inV]
;; it doesn t like this call...
(create-edge this outV label inV nil))
第二种方法试图将第一种方法称为:
java.lang.RuntimeException: Unable to resolve symbol: create-edge in this context
在我以第一种功能汇编后,我有两项定义,然后回过来,并增加了第二项。
但是,当我把议定书定义移入一个单独的档案并试图重新编造整件材料时,当第二种方法试图将第一种方法称为第一种方法时,就会犯错误,因为第一种方法尚未界定。
The Clojure reification
docs have this comment:
If a method is overloaded in a protocol/interface, multiple independent method definitions must be supplied.
我假定这些定义不是independ<>/em>。
这样做的正确途径是什么?