larry google groups <lawrencecloj...@gmail.com> writes:

> I copy and paste the example to my REPL in emacs. Everything seems to
> work fine, and I get the correct answer, and yet at the end I see a
> message that says Agent Failed. Why? What does it mean?
>
> This is from my REPL:
>
> user> (def x (promise))
> (def y (promise))
> (def z (promise))
>
> (def task-z (future (deliver z (+ @x @y))))
> (def task-x (future (deliver x 10)))
> (def task-y (future (deliver y 5)))
>
> (send-off (agent nil) (print @z))
                        ^^^^^^^^^^

The second arg given to send-off needs to be a function that is applied
to the agent's current state.  (print @z) prints the value of z and
returns nil, which is no function.  Internally send-off will execute
(apply nil nil) where the first nil is the function (which it is not),
and the second nil is the current state of the agent, and that errors.

That's probably only a typo and should be #(print @z).

Bye,
Tassilo

-- 
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