Re: Lisp Macros in Mathematica (Re: If Scheme is so good why MIT
- To: mathgroup at smc.vnet.net
- Subject: [mg102520] Re: Lisp Macros in Mathematica (Re: If Scheme is so good why MIT
- From: Pillsy <pillsbury at gmail.com>
- Date: Wed, 12 Aug 2009 04:34:23 -0400 (EDT)
- References: <firstname.lastname@example.org> <email@example.com>
On Aug 9, 6:17 pm, fft1976 <fft1... at gmail.com> wrote:
> On Jul 21, 5:31 am, Xah Lee <xah... at gmail.com> 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?
Mathematica evaluation is based on a rule-rewrite system, so
comparisons with more conventional languages like Lisp can be tricky,
but it provides the ability (through the Hold/HoldPattern/HoldComplete
facilities) to prevent code from being evaluated, and Mathematica code
is built out of data structures that you can easily manipulate from
You can also specify that functions Hold their arguments. Together,
that gives you something that approximates the Lisp macro system in
> How do you write some simple Lisp-like macros in
With difficulty. I find the absence of quasiquotation makes things
dramatically more difficult, and there's a mix of different functions
(the aforementioned Hold* functions and Unevaluated) that kind of act
like Lisp's QUOTE but not really, and unquoting is also a good deal
trickier. Mathematica's powerful pattern-matching and rule-rewriting
facilities don't close the gap IMO.
On top of that, the documentation that comes with Mathematica isn't
particularly helpful when it comes to doing macro-like things, and
there isn't anything like the reams of good tutorial material there is
on writing Lisp macros.
> Are Mathematica's macros like Scheme's hygienic macros or
> like Lisp's "low-level" macros?
More like Lisp's "low-level" macros, but you have to deal with a
number of Mathematica functions that try (with mixed results) to
prevent name clashes for you and, as often as not, defeat their
efforts. Also, in Mathematica, there apparently aren't any real
gensyms; the closest equivalent, Unique, actually interns the unique
symbols it creates.
Prev by Date:
Re: video on Presentations by Williams and Park
Next by Date:
Re: Sticky scaling? (for printing)
Previous by thread:
Re: Lisp Macros in Mathematica (Re: If Scheme is so good
Next by thread:
Formatting MatrixPower in TraditionalForm