deftype
的构造函数的一个简单案例(deftype Atom [v]
...)
我想要将v包裹在原子中以便
@(.v (Atom. 1)) => 1
这可能吗?
答案 0 :(得分:3)
不。如果你真的想要使用构造函数的OO方式,那么你需要使用gen-class。
在功能世界中,使用函数非常简单。
(defn createAtom [v] (Atom. (atom v)))
@(.v (createAtom 1)) => 1
答案 1 :(得分:0)
以前曾问过同样的问题,请看:Add constructor to deftype created class