2024 Clojure状态调查!分享您的想法。

欢迎!请参阅关于页面以了解更多有关这种工作的信息。

0
@ core.async

在go-loop或包含循环的go块内部进行类型提示会丢失类型提示信息。看起来必须从通道中读取才能丢失数据。

`
user=> (require ['clojure.core.async :as 'async])
nil
user=> (import 'java.util.Date)
java.util.Date
user=> (set! warn-on-reflection true)
true
user=> (let [a [(Date.) (Date.)]]
#=> (async/go-loop []
#
=> (when (async/<! ch')
#=> (println (.getDate ^Date (get a 0)))
#
=> (recur))))
反射警告,/tmp/form-init7283017118477479525.clj:3:3 - 无法解析java.lang.Object上的字段getDate。

object[clojure.core.async.impl.channels.ManyToManyChannel 0x2572eb4e "clojure.core.async.impl.channels.ManyToManyChannel@2572eb4e"]

user=> (let [a [(Date.) (Date.)]]
#=> (async/go-loop []
#
=> (when (async/<! ch')
#_=> (println (.getDate ^Date (get a 0))))))

object[clojure.core.async.impl.channels.ManyToManyChannel 0x12e8b6a3 "clojure.core.async.impl.channels.ManyToManyChannel@12e8b6a3"]

user=> (let [a [(Date.) (Date.)]]
#=> (async/go-loop []
#
=> (println (.getDate ^Date (get a 0)))
#=> (throw (Exception. "repl abort"))
#
=> (recur)))
12

object[clojure.core.async.impl.channels.ManyToManyChannel 0x1b48111e "clojure.core.async.impl.channels.ManyToManyChannel@1b48111e"]

线程"async-dispatch-1"中发生异常java.lang.Error: java.lang.Exception: repl abort

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1155)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

原因:java.lang.Exception: repl abort

at user$eval1611$fn__1618$state_machine__6321__auto____1621$fn__1623$fn__1625.invoke(form-init7283017118477479525.clj:3)
at user$eval1611$fn__1618$state_machine__6321__auto____1621$fn__1623.invoke(form-init7283017118477479525.clj:2)
at user$eval1611$fn__1618$state_machine__6321__auto____1621.invoke(form-init7283017118477479525.clj:2)
at clojure.core.async.impl.ioc_macros$run_state_machine.invokeStatic(ioc_macros.clj:973)
at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:975)
at user$eval1611$fn__1618.invoke(form-init7283017118477479525.clj:2)
at clojure.lang.AFn.run(AFn.java:22)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
... 2 more

`

1 答案

0
参考:https://clojure.atlassian.net/browse/ASYNC-207 (由wickedshell报告)
...