clojure中的嵌套类型?
在clojure中,如何键入我创建的类型?(我想嵌套类型。) e、 g.我原以为这会奏效:clojure中的嵌套类型?,clojure,deftype,Clojure,Deftype,在clojure中,如何键入我创建的类型?(我想嵌套类型。) e、 g.我原以为这会奏效: (deftype A [#^somePrimitive someField]) (deftype B [#^A Avalue]) 这将显示一条错误消息: Unknown location: error: java.lang.ClassNotFoundException: A 注意:clojure类型是一项新功能,目前仅存在于clojure的“new”分支中 编辑:我被cloj
(deftype A
[#^somePrimitive someField])
(deftype B
[#^A Avalue])
这将显示一条错误消息:
Unknown location:
error: java.lang.ClassNotFoundException: A
注意:clojure类型是一项新功能,目前仅存在于clojure的“new”分支中
编辑:我被clojure for java和clojure类型中不同的类型暗示方式弄糊涂了。
java类被暗示为
#^java.some.class
而clojure类型则暗示为:
#^:some.Namespace/type
(deftype B[#^:user/A Avalue])对我来说很有用。对于每个deftype,都会创建一个类型标记(基本上是一个命名空间限定的关键字),这样您就不必在使用生成的类之前编译代码 如果类型A位于当前命名空间中,则可以这样编写:
(deftype B [^::A Avalue])
对于其他命名空间中的类型,请使用其命名空间限定关键字:
(deftype B [^:user/A Avalue])
这似乎是可行的,但是我如何在其他文件中做同样的事情呢+无论如何,是的,我现在明白了。非常感谢。