Hi Paul,

Here is a real-world, production software example of the advantage of
values+refs over mutable objects and locks. A Datomic user reported the
following stack trace as a potential bug:

12:45:43.480 [qtp517338136-84] WARN  c.v.a.s.p.e.UnknownExceptionHandler -
UnknownExceptionHandler: null
java.util.ConcurrentModificationException: null
       at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:819)
~[na:1.7.0_07]
       at java.util.ArrayList$Itr.next(ArrayList.java:791) ~[na:1.7.0_07]
       at clojure.core.protocols$fn__5871.invoke(protocols.clj:76)
~[clojure-1.4.0.jar:na]
       at clojure.core.protocols$fn__5828$G__5823__5841.invoke(protocols.clj:13)
~[clojure-1.4.0.jar:na]
       at clojure.core$reduce.invoke(core.clj:6030) ~[clojure-1.4.0.jar:na]

I immediately had 99% confidence that the bug was in user code, and even a
pretty good idea what went wrong.  A call to "reduce" is a functional
transformation, and it expects to be passed values.  The exception clearly
indicates a violation of that contract, and is caused by cross-thread
aliasing and mutation in the calling code.

Regards,
Stu





On Sun, Dec 2, 2012 at 11:03 AM, Paul Butcher <p...@paulbutcher.com> wrote:

> All,
>
> I have a request which I hope the members of this group are uniquely
> positioned to help with. I have recently started working on a new book for
> The Pragmatic Programmers with the working title "Seven Concurrency Models
> in Seven Weeks" (it follows on from their existing "Seven Languages" and
> "Seven Databases" titles).
>
> One of the approaches that I'll be covering is STM, and I'll be presenting
> it in Clojure.
>
> What I'd like to solicit are "war stories" about problems you've solved
> using STM, which demonstrate the strengths of the technique over and above
> (say) threads and locks.
>
> I'm looking for real-world examples instead of presenting yet another
> hackneyed atomically-make-a-bank-account-withdrawal :-)
>
> Very many thanks in advance for your help!
>
> --
> paul.butcher->msgCount++
>
> Snetterton, Castle Combe, Cadwell Park...
> Who says I have a one track mind?
>
> http://www.paulbutcher.com/
> LinkedIn: http://www.linkedin.com/in/paulbutcher
> MSN: p...@paulbutcher.com
> AIM: paulrabutcher
> Skype: paulrabutcher
>
>  --
> 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 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

Reply via email to