Casting SPELs
Now we're going to learn an incredibly powerful feature of Lisp: Creating SPELs!
SPEL is short for "Semantic Program Enhancement Logic" and lets us create new behavior inside the world of our computer code that changes the Lisp language at a fundamental level in order to customize its behavior for our needs- It's the part of Lisp that looks most like magic. To enable SPELs, we first need to activate SPELs inside our Lisp interpreter (Don't worry about what this line does - advanced Lispers should read my short essay.)
      (defmacro defspel (&rest rest) `(defmacro ,@rest))
Ok, now that they're enabled, let's cast our first spell, called `walk`:
      (defspel walk (direction)
        `(walk-direction ',direction))
What this code does is it tells the Lisp interpreter that the word `walk` is not actually the word `walk` but the word `walk-direction` and that the word `direction` actually has a quote in front of it, even though we can't see it. Basically we can sneak in some special code inbetween our program and the interpreter that changes our code into something else before it is interpreted.
<< begin < previous - next > end >>