Finally finished going through the Casting SPELs in Lisp tutorial. Really interesting to find something along the lines of why's poignant guide to ruby complete with its own illustrations and metaprogramming (macros in Lisp). It is also similar to what Python Programming for the Absolute Beginner does for Python.
It gives a nice introduction to what you can do in Lisp. However, I am not sure if someone who does not know Lisp (or any other functional language) can appreciate this tutorial. The author, Conrad Barski, seems to skim over some thing that I view as important. For instance while using
mapcar he explains it tersely as:
"mapcar simply applies another function to every object in the list..."Most programming languages do not provide the luxury of using something similar to
mapcharas an underlying characteristic of the language. You could hack it in but most people would not do it this way since the language itself does not expose this functionality.
Conrad's explanation of macros is a bit short too. A bit too short for people to actually grasp the power of it. He also makes
defspel as an alias to
defmacro because he believes that most people who think they know macros are being delusional about it. Or as he says it:
"Often, when I try to explain the concept of macros to somebody who has only used other languages, I'll get a response like "Oh yeah! There's macros like that in C++, too!". The moment this happens, it becomes very difficult to explain "true macros", because of the semantic load on the word "macro". After all, "true macros" really are a lot like C++ macros, in that they are a way to talk to the compiler with modified code..."
I have not been using Lisp long enough to decide whether the liberal use of list (this sounds a bit ironic since Lisp is all about lists!) to store information is a good idea. For this simple example it seems decent enough since you can easily remember that the second list in the
location list tells you where to go next. If we were to do this in Java, using arrays to store such things could easily put you as having Primitive Obsession - not using objects for "little" things as coined by Martin Fowler in Refactoring.
Anyway, this short tutorial did expose me to some Lisp concepts which I have not encountered in the Little Lisper (one of the best books possible on Lisp, I think). And it was rather fun to see how one would use Lisp to create a text based game.Tweet
comments powered by Disqus