Clojure中类型提示的范围?
我正在寻找Clojure中类型提示范围的信息,例如,如果我编写Clojure中类型提示的范围?,clojure,clojure-java-interop,Clojure,Clojure Java Interop,我正在寻找Clojure中类型提示范围的信息,例如,如果我编写 (defn big-add [^BigInteger x y] (.add x y)) 那和我的一样吗 (defn big-add [^BigInteger x ^BigInteger y] (.add x y)) ??假设我写信 (defn big-sum ([] BigInteger/ZERO) ([^BigInteger x] x) ([^BigInteger x & more] (.add x (a
(defn big-add [^BigInteger x y] (.add x y))
那和我的一样吗
(defn big-add [^BigInteger x ^BigInteger y] (.add x y))
??假设我写信
(defn big-sum
([] BigInteger/ZERO)
([^BigInteger x] x)
([^BigInteger x & more] (.add x (apply big-sum more) )))
Clojure是否假设more
中充满了biginger
?假设我不想告诉你?我会做类似的事情吗
(defn foo [^BigInteger x & ^Long more] ...)
? 只需将warn on reflection设置为true,然后使用无法解析类型的函数测试表达式
答复:
最后
(defn testo [s & ^java.lang.String more]
(.charAt (first more) 1))
=> CompilerException java.lang.RuntimeException: & arg cannot have type hint, compiling:(NO_SOURCE_PATH:1:1)
您的每个问题的简短答案都是否定的:(
(defn testo [s & ^java.lang.String more]
(.charAt (first more) 1))
=> CompilerException java.lang.RuntimeException: & arg cannot have type hint, compiling:(NO_SOURCE_PATH:1:1)