Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Clojure:ns resolve->;获取代理->;打电话给我_Clojure - Fatal编程技术网

Clojure:ns resolve->;获取代理->;打电话给我

Clojure:ns resolve->;获取代理->;打电话给我,clojure,Clojure,最小故障情况: (ns test) (def a (agent "hello")) (send a (fn [x] "world")) ; works (send (ns-resolve 'test 'a) (fn [x] "test")) ; fails 问题: 为什么最后一行失败了 这是代码热加载系统的一部分。我必须使用ns解决方案 有没有办法让这一切顺利进行 谢谢 ns resolve返回一个var,而不是var(代理)的值。您需要取消对var的引用以获取值: (send (der

最小故障情况:

(ns test)

(def a (agent "hello"))

(send a (fn [x] "world")) ; works

(send (ns-resolve 'test 'a) (fn [x] "test")) ; fails
问题:

为什么最后一行失败了

这是代码热加载系统的一部分。我必须使用ns解决方案

有没有办法让这一切顺利进行


谢谢

ns resolve返回一个var,而不是var(代理)的值。您需要取消对var的引用以获取值:

(send (deref (ns-resolve 'test 'a)) (fn [x] "world"))
;; or
(send @(ns-resolve 'test 'a) (fn [x] "world"))