For Kenny Tilton: Why do I need macros revisited.

Andrew Dalke adalke at mindspring.com
Fri Aug 22 04:09:40 EDT 2003


Kenny Tilton:
> You are absolutely right. Metaclasses are killer. I am surprised
> Pythonistas afraid of macros let them into the language!

Speaking personally, I still haven't wrapped my head around
them, and despite seeing Alex's talk about them, don't fully
understand when to use them.  I've seen David Mertz' xml_pickle
code which makes good use of them, but don't yet follow
how it works.

> Lispniks have not seen code become unreadable because of macros. That is
> something you all (well, most) are imagining. You are almost positing it
> as given. And it is simply not so.

Terry Reedy pointed out something from some Scheme documentation
found by Dave Kuhlman:
http://www.schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-3.html#%_sec_
Temp_4
] As Scheme became more widespread, local dialects began to
] diverge until students and researchers occasionally found it difficult
] to understand code written at other sites.

I cannot say if that's because of macros or other aspects of Scheme.
People I know who used Lisp and loved macros reported that macros
were a big part of dialecticazation.  See previous posts of mine for
full references.

As I mentioned elsewhere, I have observational evidence that
Lisp/Scheme do not promote community growth in my fields of
interest - computational chemisty and biology - anywhere near
as much as Perl, Python, Java, or Ruby.  While I do not believe
it's because of macros, I do belive it's because Lisp/Scheme's
tendency towards increasing the flexibility and power available
to a single programmer which reduces its usefulness in the sorts
of development environments common to my field.

That's not to say there can't be teams of Lisp programmers;
just that the type of people who prefer Lisp are not usually
biologists or chemists.

> We have pointed out again and again
> that macros are no harder to understand than functions or classes, but
> no one addresses that point.

What about Terry's comment, based on the above URL:
) Reading the third referenced page on Macros, I notice that the amount
) of syntax definition for the macro sublanguage is as large as a
) substantial portion (one-third?) of that for core Python (if condensed
) to the same density). So, just by definitional bulk, having it in the
) language would not be a free ride.

> Strangely, quite a few of you have also conceded macros can leverage a
> language.

Leverage a language ... for what?  And for whom?  For smart people
who can perceive the semantics directly, with little need for syntactical
clues and who "don't look at anyone else's code (if you have to work
on  it, rewrite it anyway) and never show [their] code to anyone" then
yes.

For the things Python excels at, not necessarily.

                    Andrew
                    dalke at dalkescientific.com







More information about the Python-list mailing list