Touch the firehose of ds106, the most recent flow of content from all of the blogs syndicated into ds106. As of right now, there have been 92514 posts brought in here going back to December 2010. If you want to be part of the flow, first learn more about ds106. Then, if you are truly ready and up to the task of creating web art, sign up and start doing it.

From Daniel – Day 3

Posted by
|
Daniel Bowen Clojure Journal Entry – Day 3

Looks like we are going into the Software Transactional memory (stm). hmm it seems we are getting into Threading here. Making sure data is locked down by restricting what can access it. Apparently this is done through these things in Clojure called references. We’ll see…

So references can only be edited within a transaction, not afterwards. You have to do a little command called dosync in order to deref something and then alter it.

wow.. atoms, and references and what can be edited how and when? …. exactly! This stuff if hard to get my head around but apparently atoms to not need to edited within a transaction. It can be edited later with swap! and reset! commands.

Ok! I’m not gonna lie, this caching thing, I don’t get it at all. Not even a little bit…. wow.

Alright, agents make a little more sense. You can define a function and give it to an agent which is like a Thread. I’m familiar with Java, so I recognize Thread/sleep 5000 which puts that thread to sleep. Other than the weird syntax, this shouldn’t be too hard to implement. Futures are kind of cool, they seem to allow for asynchronous calls which wait for returns before executing. This seems like a mutex in other languages where you wait until the execution is finished and then continue.

Finishing up Day 3 there, it seems like multimethods allow Clojure to behave like JavaScript in that you can associate libraries of functions with a type. Thread states allow for variable binding that is Thread specific, I picture this like a local variable in function but with a Thread instead.

That finishes up Day 3 of Clojure in Seven Languages in Seven Weeks. I will continue to evaluate Clojure in the way we evaluated SML with looking at different aspects of the language.

Danny

Add a comment

ds106 in[SPIRE]