Tuesday, March 10, 2009

My head hurts.

I've just spent three days trying to understand Clojure's for macro. And I reckon I have another couple of days worth of work pulling it apart yet.

It's a bit of a disservice calling it for, as it is actually a list comprehension, but it is called for because this is the construct to use when a traditional programmer would reach for a for loop.

It has iteration, variable binding, and choice. It is actually a baby programming language in a 30 odd line macro. I can see the parallels between this macro and the de-sugaring that haskell does with the monadic do blocks.

But still, it is a mind warping exercise pulling apart this macro. Fun tho. =)