This post originated from an RSS feed registered with Ruby Buzz
by Joey Gibson.
Original Post: Lisp Macros Are Very Cool
Feed Title: Joey Gibson's Blog
Feed URL: http://www.jobkabob.com/index.html
Feed Description: Thoughts, musings, ramblings and rants on Java, Ruby, Python, obscure languages, politics and other exciting topics.
So I'm playing around with Lisp,
reading Successful Lisp
and thoroughly enjoying myself. I really like Lisp, I just haven't
gotten to use it on anything other than test stuff yet. One of the
things that I find the most interesting, and powerful, is the macro
facility. Sure, some languages like C have macros that are processed
by a preprocessor, but Lisp's macros are in a league of their
own. Consider this code (lifted wholesale from Successful Lisp)
will define two functions, one called save-checks and the
other called load-checks, that will store and retrieve the
global variables *checks*, *next-check-number* and *payees*
to and from a given file name. These methods could be called thusly
This macro could be included in any
program for which we needed to have reader and writer functions for
marshaling data to and from disk files. This example was for a
fictional bank, but let's say I had a program to process data about
the Tour de France and I had
buckets for teams, riders, jerseys and sponsors. I could do this