On Wednesday, September 10, 2014 11:05:36 AM UTC-5, puzzler 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. >
I do not think there is a hard definition of what ! means as a suffix. 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 transaction. Only vswap! and > vreset! require the exclamation point. > The name is not going to change, sorry. 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. > vswap! and vreset! do something similar in shape but different in meaning than swap! and reset! (they are non-atomic). As with all the stateful containers, the functions are specific to the container type (alter-var-root, alter, send, etc). > > --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.