

Common Lisp Reader Macros: A Simple Introduction - mahmud
http://dorophone.blogspot.com/2008/03/common-lisp-reader-macros-simple.html

======
stcredzero
The light just went on for me!

Imagine if your favorite programming language, X, had some sort of facility to
expose a function/method's Abstract Syntax Tree and a meta-language for
scripting changes to particular patterns of in the AST or activating different
functionality. Well, in Lisp, the language is also it's own Abstract Syntax
Tree and it's own meta-language.

(I use a Smalltalk meta-language all the time at work for code transformation,
but even with such a facility Smalltalk can't quite do everything Lisp macros
can do.)

------
chollida1
If you want to learn more about Common Lisp reader macro's then I suggest
getting a copy of Let Over Lambda( <http://letoverlambda.com/> )

I found it to be a great resource on a topic that is often ignored by people
coming to Common Lisp.

------
alan-crowe
As the post notes a read macro is not a kind of macro. Nevertheless his
example is in competition with a macro based approach to the problem. One
might wish for a variant on DEFUN say DEFVN so that one can say

    
    
        (defvn square (x)
          (* x x))
    

and get both (square 3) => 9 and (square #(1 2 3)) => #(1 4 9). This is not
hard; to show off the short paste at <http://paste.lisp.org/+24PP> one needs a
fancier example

    
    
        (defvn times (&rest v)
          (reduce #'* v))
    

lets (times 2 3 5) => 30, (times #(2 3) 5) => #(10 15), and (times #(1 10 100)
2 #(3 5 7) 0.1) => #(0.6 10.0 140.0)

