Thanks for the pointers both. What still riddles me is why the above
script with the first formula (with the deref problem) doesn't always
cause a problem, but maybe one in every 5 times I run it.

@Timothy - double thanks for your clarifications. I am changing my
program from a ref-based to a send / agent-based.. I'm somewhere half
between now :P.

On Jan 18, 3:42 pm, Timothy Pratley <timothyprat...@gmail.com> wrote:
> > (defn death
> >   [host]
> >   (dosync
> >    (if (not (empty? @host))
> >      nil)))
>
> The agents initial value is a ref. Sometimes you set it to nil. nil
> cannot be dereferenced. Perhaps you meant to set the ref to nil (if
> (not-empty @host) (ref-set host nil)).
>
> However I think you've gone a little off track mixing agents and refs
> like this. The value of an agent is already thread safe, so there is
> no need to protect it with a ref.
> (def myagent (agent 5))
> (defn death [host] (if host nil))
> (send death myagent)
>
> > (defn death
> >   [host]
> >   (dosync
> >      nil))
>
> This just returns nil all the time, no deref is done.
--~--~---------~--~----~------------~-------~--~----~
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
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