Question

In the Rich Hickey Code here he wraps his Clojure Ants code in a sync function (when one would idiomatically expect dosync).

When we look at the doco for sync here, we see

Same as dosync but allows for extra options (which are not currently supported). Probably best to use dosync instead at the moment.

My question is - what are the extra transaction flags intended (or even possible) for the dosync operator? Is it like database transaction isolation levels, where you have different settings like read-committed etc.

Was it helpful?

Solution

There are no possible flags that will have any effect. The macro declaration for sync is:

 (defmacro sync 
   [flags-ignored-for-now & body]
   `(. clojure.lang.LockingTransaction
       (runInTransaction (fn [] ~@body)))) 

So you can put anything you would like there ;-) This is used in the ants demo because when that demo was written the language was evolving and it was thought that some flags would be needed, which turned out not to be the case.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top