Agents combine two things 1) a queue of functions, 2) mutable state. The key thing about agents is that they still respect Clojure's concept of "instant deref". That is to say, you can always deref an agent even if the queue is backlogged. This is one of the key differences between agents and actors. You have to send a message to an actor to deref it, an agent is always deref-able.
Now it's true that you could build an agent via a core.async channel and an atom, but there's really no need since agents already exist in the runtime. Agents also support the lesser known features of Clojure's mutable refs, namely, validators and watchers. But the short answer is: agents existed before core.async. I've used them once in the past 2 years, but that's not to say they aren't useful sometimes. And it's nice being able to have a queue attached to a mutable reference without having to import core.async. On Thu, Oct 13, 2016 at 7:28 PM, Timothy Baldridge <tbaldri...@gmail.com> wrote: > >> When using clojurescript, adding async really increases the load time. > That's one place where you might want to use agents when you can. > > But Clojurescript doesn't support agents. > > On Thu, Oct 13, 2016 at 7:16 PM, William la Forge <laforg...@gmail.com> > wrote: > >> On Thursday, October 13, 2016 at 3:38:16 PM UTC-4, larry google groups >> wrote: >>> >>> So when to use agents? I've looked through Clojure repos on Github, >>> looking for uses of agents, and I found very few. (I was writing a blog >>> post about concurrency in Clojure, and I found that agents are among the >>> least used tools for concurrency). I found a lot of uses of futures and >>> promises and channels and core.async, and certainly atoms, but I didn't >>> find many uses of agents. When are agents best used? >>> >>>> >>>>> >> When using clojurescript, adding async really increases the load time. >> That's one place where you might want to use agents when you can. >> >> >> -- >> 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 unsubscribe from this group and stop receiving emails from it, send an >> email to clojure+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > “One of the main causes of the fall of the Roman Empire was that–lacking > zero–they had no way to indicate successful termination of their C > programs.” > (Robert Firth) > -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.