Right...
Is there a way to force an agent thread to be evaluated in a certain
namespace?

You see, the current design accepts a string, and uses read-string to
parse it. i.e. I call a form like this a lot

(send test-query conj (read-string (get-input)))

Sean

On Apr 29, 4:40 pm, Laurent PETIT <laurent.pe...@gmail.com> wrote:
> Hello Sean,
>
> You want
>
> (def test-query
>  (agent
> `[test-coll
>     (take 2)]))
>
> to fully qualify test-coll (and also take, btw) because when passed to
> eval on the agent's thread, who knows to which value *ns* will be
> bound ?
>
> (tested on my machine)
>
> HTH,
>
> --
> Laurent
>
> 2010/4/29 Sean Devlin <francoisdev...@gmail.com>:
>
>
>
>
>
> > I'm having a lot of trouble getting an app to work.  I'm using agents
> > in a GUI app.  For the sake of discussion I've got the following
> > things defined:
>
> > (def test-coll
> >  [{:a 1 :b 2 :c 3}
> >   {:a 4 :b 5 :c 6}
> >   {:a 7 :b 8 :c 9}
> >   {:a 10 :b 11 :c 12}
> >   ])
>
> > (def test-query
> >  (agent
> >  '[test-coll
> >     (take 2)]))
>
> > (def test-result (agent []))
>
> > I want to execute test-query like so:
>
> > user=> (eval `(->> ~@(deref test-query)))
> > ({:a 1, :b 2, :c 3}
> >  {:a 4, :b 5, :c 6})
>
> > This part works at the REPL fine.  Next I wrap it in a closure:
>
> > user=> ((fn [& args] (eval `(->> ~@(deref test-query)))))
> > ({:a 1, :b 2, :c 3}
> >  {:a 4, :b 5, :c 6})
>
> > Also fine.
>
> > Now, I want to send this to the agent test-result
>
> > user=> (send test-result (fn [& args](eval `(->> ~@(deref test-
> > query)))))
> > #<Agent (...)>
>
> > user=> @test-result
> > #<CompilerException java.lang.Exception: Agent has errors
> > (NO_SOURCE_FILE:468)>
>
> > user=> (agent-errors test-result)
> > (#<CompilerException java.lang.Exception: Unable to resolve symbol:
> > test-coll in this context (NO_SOURCE_FILE:459)>)
>
> > Blargh.
>
> > Why doesn't this work when I use send?  I'm at a loss here.
>
> > Sean
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to clojure@googlegroups.com
> > Note that posts from new members are moderated - please be patient with 
> > your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/clojure?hl=en
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group 
> athttp://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to