[pro] The Best Examples of "Code is Data"

Daniel Weinreb dlw at itasoftware.com
Tue Sep 28 21:42:07 UTC 2010



Daniel Gackle wrote:
> Vladimir touches on two important things.
>
> A lot of the value in Lisp macros is how simple they make certain
> things. People sometimes ask for an example of macros that "can't be
> done without them" - but that's a contradiction. By definition,
> anything that can be done by a macro can be done by its expansion.  It
> can't, however, necessarily be done as easily. But this is a harder
> debate to have because "easy" gets so subjective so quickly.
I would say that the real point is that the macro is a new
way to separate concerns, or a new way to do abstraction.
Just as object-oriented programming (and aspect-oriented
programming) are ways of doing abstraction that are
useful in specific circumstances, so are macros.
There are kinds of abstraction that are not clear,
or not possible, otherwise.

>
> Second, SETF is really apropos. One of the places I often find macros
> making things easier is in eliminating boilerplate code that involves
> assigning values to things.
I agree, but would go farther.  It eliminates all kinds of boilerplate.

I read Java code written by Java experts and so much of it
is boilerplate, such as Java Beans with lots of get and
set functions and nothing happening.  When I point
this out, they say, oh, no problem, Eclipse just
writes those for you.  Well, when they enhance
Eclipse so that it reads them for you too, OK, but
then you have macros for all real purposes.

-- Dan





More information about the pro mailing list