This document appears to be notes from a presentation on Clojure. It discusses key features of Clojure like how it differs from Lisp, its use of REPL for documentation, lambda functions and macros. A large portion of the document covers concurrency in Clojure, explaining concepts like STM, atoms and agents. It provides examples of using Clojure's STM functions like ref, deref, alter and compares them to handling concurrency in other languages like Scala. The notes conclude by mentioning side-effects and comparing Clojure to other JVM languages.
31. (about STM)
$x = STM.new []
STM
def push_pop(val)
retval = nil
$x.transaction do |v|
v << val
retval = v.pop
end
retval
end
2010 7 16
32. (about STM)
Thread A Thread B
$x.transaction do |v| $x.transaction do |v|
v << val v << val
retval = v.pop retval = v.pop
end end
2010 7 16
33. (about STM)
Thread A Thread B
$x.transaction do |v| $x.transaction do |v|
v << val v << val
retval = v.pop retval = v.pop
end end
2010 7 16
34. (about STM)
Thread A Thread B
$x.transaction do |v| $x.transaction do |v|
v << val v << val
retval = v.pop retval = v.pop
end end
2010 7 16
35. (about STM)
Thread A Thread B
$x.transaction do |v| $x.transaction do |v|
v << val v << val
retval = v.pop retval = v.pop
end end
2010 7 16
36. (about STM)
Thread A Thread B
$x.transaction do |v| $x.transaction do |v|
v << val v << val
retval = v.pop retval = v.pop
end end
Thread A $x
2010 7 16
37. (about STM)
Thread A Thread B
$x.transaction do |v| $x.transaction do |v|
v << val v << val
retval = v.pop retval = v.pop
end end
Thread B
2010 7 16