That's also my explanation about the use of exclamation mark. IMHO, +1 for volatile, without !.
Plínio On Wed, Sep 10, 2014 at 1:05 PM, Mark Engelberg <mark.engelb...@gmail.com> wrote: > When I explain to new Clojurists what the ! means, I explain that it calls > attention to a mutation function that is unsafe to call inside a > transaction. Many programmers coming from Scheme are used to thinking of ! > as meaning *anything* involving mutation, but that's not the case in the > Clojure. This more subtle distinction (that it needs to be unsafe in a > transaction) clarifies why swap! has an exclamation point, but ref-set does > not, even though both involve mutation. > > Assuming my description of Clojure's use of ! is correct (and if I'm wrong > and am not thinking of some important counterexample, please let me know), > then it doesn't really make sense for volatile to be called volatile!. > Yes, volatiles are less safe than atoms, but the creation of the volatile > itself is perfectly fine to occur in a transation. Only vswap! and vreset! > require the exclamation point. > > I'd go one step further and question why we need new names vswap! and > vreset!, when swap! and reset! are perfectly clear and sufficient. As > Clojure has become increasingly interface and protocol-driven, it makes > less and less sense to have a proliferation of function names for the same > behavior on different underlying objects. vswap!, for example, is exactly > the semantics you'd expect if you overloaded swap!, describing it as a > function that can be applied to both atoms and volatiles, where volatiles > are the more thread-unsafe, less atomic, alternative, because that's the > nature of the underlying box. > > --Mark > > -- > 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. > -- 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.