MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Lisp Macros in Mathematica (Re: If Scheme is so good

  • To: mathgroup at
  • Subject: [mg102493] Re: [mg102451] Lisp Macros in Mathematica (Re: If Scheme is so good
  • From: David Bakin <davidbak at>
  • Date: Tue, 11 Aug 2009 04:04:40 -0400 (EDT)
  • References: <>

It is very easy to make what Lisp calls "special forms". You use HoldAll or
related attributes to create your own "special forms", then manipulate the
arguments in their full form (aka S-expressions), evaluating things when you

As far as I am aware you do not get reader syntax like quotes and
quasiquotes that make Lisp macros easy to write.  But depending on what
you're trying to do you may not need them.  With Mathematica you get full
pattern matching on arguments (not just destructuring) and rule-based
programming, and everything else that Mathematica provides.  You may find
these features are even more effective than quoting and quasiquoting in
writing macros.

BTW, Mathematica does not need a separate defmacro call that basically means
"define this function such that you don't evaluate any arguments, but when I
return the result, you evaluate it".  That is because 1) To get the first
part you add the HoldAll attribute to your function name, and 2) Mathematica
automatically evaluates the result returned by any/all functions, until
there's nothing more to evaluate (which is an important difference between
the Lisp REPL and the Mathematica REPL).

  -- David

(By the way, I googled for the source of your quotation, and I'm glad you
didn't bother to quote more of his rant on this elist. That guy may have
something interesting to say but it hard to figure out what because
apparently he is like Steve Martin at the airline counter in Planes, Trains,
and Airplanes - unable to say anything unless it is composed of at least 30%
f**k-variations.  Painful to read.)

On Sun, Aug 9, 2009 at 3:20 PM, fft1976 <fft1976 at> wrote:

> On Jul 21, 5:31 am, Xah Lee <xah... at> wrote:
> > Also, lisp's macros, a feature that gets lispers much ado about
> > nothing. In Mathematica (b ~1989), the whole language can be
> > considered as a extended lisp macros system. When i learned about
> > lisp's macros while practical coding elisp, i find lisp macros are
> > rather so trivial, painful to use, and laughable.
> Is this true? How do you write some simple Lisp-like macros in
> Mathematica? Are Mathematica's macros like Scheme's hygienic macros or
> like Lisp's "low-level" macros?

  • Prev by Date: Re: Re: Re: video on Presentations by Williams
  • Next by Date: Re: Re: Re: error with Sum and Infinity
  • Previous by thread: Re: Thoughts on a Wolfram Alpha package for ...
  • Next by thread: Re: Lisp Macros in Mathematica (Re: If Scheme is so good