On Mon, Dec 29, 2008 at 12:40 PM, Rich Hickey <richhic...@gmail.com> wrote:
> People who know what they are doing can do these things right now with
> Clojure's array support. There really isn't any more value for Clojure
> to add to that, so no special primitives. I fully accept the necessity
> of doing that at times, and the correctness of internally mutating,
> but externally referentially transparent functions, and Clojure has
> several of them. That's one of the reasons Clojure isn't 'pure'. OTOH
> it's not a good argument for mutable local vars. What other "unsafe
> things" are you looking for?

After giving this some more thought, I think the absolutely simplest
way to further improve Clojure's mutability support would be to add an
atom-set function for the cases where you really want to clobber the
contents of atom and don't care what the contents already are.  This
takes the "variable which needs no synchronization" thing one step
further, allowing for fastest speed in those situations.

The semantics would be like this:
(defn atom-set [a val]
  (swap! a (constantly val)))

But presumably it could be implemented in the Clojure core in a way
that is even faster than the above implementation, since it doesn't
need to do the check that the contents haven't changed before setting.
 I think this is consistent with the idea of atom as a power-user's
tool for getting the best possible performance when synchronization is
not required.

--~--~---------~--~----~------------~-------~--~----~
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