Reputation: 2753
Minimal failure case:
(ns test)
(def a (agent "hello"))
(send a (fn [x] "world")) ; works
(send (ns-resolve 'test 'a) (fn [x] "test")) ; fails
Question:
Why does the last line fail?
This is part of a code hot-loading system. I have to use ns-resolve.
Is there a way to make this work?
Thanks!
Upvotes: 1
Views: 244
Reputation: 17773
ns-resolve returns a var, not the value of the var (the agent). you need to deref the var to get the value:
(send (deref (ns-resolve 'test 'a)) (fn [x] "world"))
;; or
(send @(ns-resolve 'test 'a) (fn [x] "world"))
Upvotes: 3