Lisp-like macros in Python?

John Nagle nagle at animats.com
Tue May 1 18:20:44 EDT 2007


Duane Rettig wrote:
> sturlamolden <sturlamolden at yahoo.no> writes:
> 
> 
>>Hello
>>
>>The Lisp crowd always brags about their magical macros. 

    I used LISP back when LISP macros were popular.
You don't want to go there.  It degrades readability
without improving the language.

    Check out the original "MIT loop macro", used to put
something comparable to a FOR statement into early versions
of LISP.

http://www.cs.cmu.edu/afs/cs/project/ai-repository/ai/lang/lisp/code/iter/loop/mit/0.html

    Note that it's at version 829.  And that was with MIT people fixing it.
That thing was a trouble spot for a decade or more.

    Scheme added a "do" statement as part of the language, which
was the right answer.  The "loop macro" was, at long last, retired
around 1991.

    There are lots of "l33t" features one can put in a language,
but in the end, they're mostly not that helpful.

    The people who advocate "l33t features" usually need to do more
maintenance programming on the code of others, to get more of a sense
of gives real, operational trouble in a programming language.
Really.  After you've fixed the bad code of others, then you're
entitled to talk about language design.

    As someone who's programmed in all too many languages and with
a background in formal proof systems, I would make few changes to
Python as a language.  (And most of the things I'd change involve
removing less-used features that constrain implementations.)
The language is fine.  The problems are elsewhere.
The CPython implementation is way too slow and some of the libraries
are flakey.  That's what needs attention.

				John Nagle



More information about the Python-list mailing list