Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2009

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

Search the Archive

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

  • To: mathgroup at
  • Subject: [mg102489] Re: Lisp Macros in Mathematica (Re: If Scheme is so good why MIT
  • From: David Bailey <dave at>
  • Date: Tue, 11 Aug 2009 04:03:56 -0400 (EDT)
  • References: <> <> <h5nht7$8nm$>

fft1976 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?

Although macros can be abused - as they are in many C programs, where 
almost everything is a macro - I'd like to see macros supported directly 
in Mathematica, because they would offer an efficient way to access 
parts of a structure by name - rather than using Part. This gives you 
clarity and speed.

I do have a scheme for doing this. It involves defining functions using 
a modified version of the := operator, which replaces macro expressions 
on the RHS of the function before saving the result in the normal way. 
Macros are defined with a Define\[Breve]Macro call prior to the 
functions that use them. I considered using $Pre or $PreRead, but these 
do not work when programs are read in with Get or in packages.

David Bailey

  • Prev by Date: Re: error with Sum and Infinity
  • Next by Date: Dynamically create array and display data graphically
  • Previous by thread: Fail to export LogLogPlot with ShowLegend
  • Next by thread: Dynamically create array and display data graphically