

Comprehensive Clojure STM Article  - fogus
http://java.ociweb.com/mark/stm/article.html

======
jrockway
_They must ensure that no data that requires coordinated changes is modified
outside an STM transaction._

How does Clojure handle this? In Haskell, the type system ensures that STM
operations can only happen where expected. (Reading a TMVar, for example,
returns something of type STM (TMVar a). This means that the enclosing
function must also return something of the type STM a. To get the actual data
out, you run the transaction, which is of type STM a -> IO a. The type system
automatically ensures that STM operations don't happen anywhere else.)

~~~
cema
In Clojure they require that all operations that affect STM are explicitly
done inside a transaction, otherwise an error is raised.

~~~
jrockway
I see, so it complains at runtime when when a transaction is not "in effect"
and someone calls a transactional function?

~~~
cema
Yes, I believe it is correct.

Keep in mind Clojure is running on top of jvm so they had to, first, figure
out a balance between being practical and being "pretty" and, second, work
within the constraints of the environment. I think Rich Hickey has done a
tremendous job here (and keeps doing it).

