In December I released a curses client allowing playback of music stored/purchased with Google Play. The client is written in python and uses Simon Weber’s unofficial Google Music API. Details can be found on the github page. It’s still a work in progress but I have been able to use it as my sole music player. Here’s a picture of what it looks like: Figure 1: Screenshot of thunner running in terminal
Today I’m going to visit two topics that I’ve not covered yet: lazy evaluation and types. Personally, the type system is the hardest thing to get my head around and I hope to write a lot more on the subject. Lazy evaluation allows for the delay of evaluation until a required time. In Shen, lazy evalation is controlled with two functions: freeze and thaw. As the names suggest freeze delays evaluation and thaw evaluates a frozen expression.
More Shen macros today. In the previous post I promised an explanation for why we don’t have/need quasiquote, unquote and unquote-splicing in Shen. Let’s look at a Common Lisp example: a single place let. This would typically be written as: (defmacro let-one ((loc val) &rest body) `(let ((,loc ,val)) ,@body)) …using quasiquote, unquote and unquote-splicing. This is actually short hand for the following: (defmacro let-one ((loc val) &rest body) (append (list 'let (list (list loc val))) body)) I think everyone would agree that this second form is harder to read.
In this post I’m going to concentrate on Shen macros; some familiarity with basic Shen and Common Lisp macros is assumed. In Shen, as in traditional Lisp style, code is data and data is code. Shen code is read in as a list datastructure: (+ 1 2) becomes [+ 1 2]. Shen macros are functions that pattern match on the list representation of code at read time in order to rewrite it.