I'd say only Rich Hickey can really answer these questions, but here is one possible explanation.
These functions are not equivalent. Just like 'send' on an agent has fundamental differences with 'swap!', 'alter' has fundamental differences with both. There is also some similarity, of course: in all three cases, the intent is to "update" the "current" value by supplying a transformation function, but: * 'swap!' will happen immediately, in the current thread, with no regard for whatever else happens; * 'send' will happen at some point in the (hopefully near) future on a different thread; * 'alter' can only be used within a transaction and will do some complex magic to coordinate changes to multiple refs. Bear in mind that Clojure is built on top of a polymorphic foundation, so names like "atom-swap!" and "ref-swap!" would not really make sense; if the point was to call them the same, they could just be called the same, like 'conj' is the same for all data structures, and like 'deref', which does have the same semantics for atoms, refs, and agents, is called the same for the three of them. In short, one possible explanation is that they were deemed sufficiently different to warrant a different name. On Friday, 19 February 2016, Atamert Ölçgen <mu...@muhuk.com> wrote: > why Clojure chose to name functions operating on refs and atoms so >> differently > > > swap! is not an alter on atoms. And vice versa. > > reset! is not a ref-set on atoms. And vice versa. > > The analogous functions names would make remembering which is which easier. > > > Are you having trouble remembering them? > > > > On Fri, Feb 19, 2016 at 7:04 AM, Tianxiang Xiong < > tianxiang.xi...@gmail.com > <javascript:_e(%7B%7D,'cvml','tianxiang.xi...@gmail.com');>> wrote: > >> I'm currently reading Practical Clojure >> <http://www.apress.com/9781430272311> by VanderHart and Sierra, and am >> on the section about state management. >> >> I'm curious why Clojure chose to name functions operating on refs and >> atoms so differently. As I understand it, >> >> swap! -> atoms, alter -> refs >> reset! -> atoms, ref-set -> refs >> >> Why "swap!" and "reset!", instead of "atom-alter" and "atom-set"? The >> analogous functions names would make remembering which is which easier. >> >> -- >> 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 >> <javascript:_e(%7B%7D,'cvml','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 >> <javascript:_e(%7B%7D,'cvml','clojure%2bunsubscr...@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 >> <javascript:_e(%7B%7D,'cvml','clojure%2bunsubscr...@googlegroups.com');>. >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Kind Regards, > Atamert Ölçgen > > ◻◼◻ > ◻◻◼ > ◼◼◼ > > www.muhuk.com > > -- > 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 > <javascript:_e(%7B%7D,'cvml','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 > <javascript:_e(%7B%7D,'cvml','clojure%2bunsubscr...@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 > <javascript:_e(%7B%7D,'cvml','clojure%2bunsubscr...@googlegroups.com');>. > For more options, visit https://groups.google.com/d/optout. > -- 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.