… And Great Responsibility

Unfortunately, along with the do stuff at the same time magic there is the inevitable hair on fire complication: without some kind of positive control mechanism, we know nothing about how fast a thread will run. The implications of this ignorance are deep and pervasive. To see these implications in action we’re going to break the rules a bit and embed some def expressions in a couple of functions:

 (​def​ fav-book ​"Jaws"​)
 
 (​defn​ make-emma-favorite [] (​def​ fav-book ​"Emma"​))
 
 (​defn​ make-2001-favorite [] (​def​ fav-book ​"2001"​))

As we saw in back in Chapter 8, Def, Symbols, and Vars, this is not a great idea: sticking a def inside of a function creates a more or less hidden side effect, making your ...

Get Getting Clojure now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.