Macros

Alan Bawden Alan@LCS.MIT.EDU
Sun, 6 May 2001 06:15:26 -0400 (EDT)


   Date: Fri, 4 May 2001 19:31:21 -0400 (EDT)
   From: Jan-Willem Maessen <earwig@abp.lcs.mit.edu>

   Alan Bawden <Alan@LCS.MIT.EDU> writes:
   > A macro facility is like a pair of vise-grips (if you don't know what
   > those are, see http://www.technogulf.com/ht-vise.htm).

   I found myself laughing heartily at this apt analogy.  I have heard
   vice grips described as "the wrong tool for every job."  (My own
   experience with vice grips backs this up).

I considered including that well-known quip in the paragraph where I tried
to make it clear that I was -not- saying the same thing about macros.
(While looking for a good online picture of vise-grips I came across a
number of vise-grip horror stories -- the best was the guy who replaced the
steering wheel in his car with a pair of vise-grips!  But I digress...)

So just to reiterate: the property of vise-grips I find analogous to a
macro facility is that the more -other- tools you have available, the less
often you need -this- one, nevertheless you still want this tool in your
tool-box.

   That being said, there are a number of things one might want out of a
   macro facility, and I think they should be carefully distinguished:

   1) The ability to name expressions without evaluating them, e.g. to
      cook up a facsimile of laziness.
   2) The ability to parrot source code (and maybe source position) back
      at the user, e.g. Alan's assert macro, or its C equivalent.
   3) The ability to create new binding constructs.
   4) The ability to create new declaration constructs.

I like this list.  I'd love to see nice elegant programming language
features for doing all of these things.  Not only would I have to write
fewer macros, but I'd probably be able to do many amazing -new- things.
(Lazyness, for example, doesn't just eliminate the need for a lot of
macros, it allows many new things that are beyond the reach of mere
macrology!)

I suspect, however, that even with everything on this list checked off, I'd
still want macros.  Because I doubt that this list is exhaustive.  The
example I pulled out of my hat led you to put item #2 on this list, but I
wonder if you would have thought of #2 if you didn't have my example before
you?  If I had picked another example, I suspect this list would have
looked different.

- Alan