Skip to content

Instantly share code, notes, and snippets.

@c-spencer
Created August 12, 2010 20:46
Show Gist options
  • Save c-spencer/521695 to your computer and use it in GitHub Desktop.
Save c-spencer/521695 to your computer and use it in GitHub Desktop.
(defprotocol TestProtocol
(test-method [this]))
(deftype MutableLocking
; Compiles ok
[^{:volatile-mutable true} mut-var]
TestProtocol
(test-method [this]
(locking this
(set! mut-var {:set true})
this)))
(deftype MutableLockingFailure
; Placing return value outside of locking
; Fails to compile, complaining mut-var is not mutable.
[^{:volatile-mutable true} mut-var]
TestProtocol
(test-method [this]
(locking this
(set! mut-var {:set true}))
this))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment