gpt4 book ai didi

java - Clojure deftype 引用其他类型

转载 作者:行者123 更新时间:2023-12-01 22:05:13 25 4
gpt4 key购买 nike

尝试使用另一种类型的一种类型似乎不起作用:

(deftype Foo [^int a ^int b])
(definterface Bars (^Foo makefoo []))

(deftype Bar [^int a ^int b] Bars (^Foo makefoo [this] (Foo. 1 2)))
;java.lang.NoClassDefFoundError: java/lang/Foo.

如何让 Foo 对 Bar 可见?

最佳答案

如果您在 definterface 中为提示指定完整的命名空间,一切似乎都能正常工作。

(ns com.bar)

(definterface Bars
(^com.bar.Foo makefoo []))

关于java - Clojure deftype 引用其他类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32928909/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com