No macros in Python

Lulu of the Lotus-Eaters mertz at gnosis.cx
Mon Dec 16 19:52:45 EST 2002


Mike Meyer <mwm at mired.org> wrote previously:
...re. function: with_output_to_file()...
|It can't be done, because the lack of a real macro facility means the
|programmer interface can't be done to my satisfaction.

Oh c'mon.  This is just childish!

What it that functions are unable to do?!

Catch exceptions?  Determine their caller's namespace?  Close open files
explicitly?  Those are the specs you mentioned that my example didn't
happen to do.  Now of course, if what it means to do it "to your
satisfaction" is "invoke without parentheses" you're right (but no one
who uses Python will ever care).

|As I said before, adding macros changes the syntax of the language,
|just like adding callable objects does. A macro doesn't change the
|syntax of python-with-macros any more than a function changes the
|syntax of python-with-callable-objects.

Well.. of course callable objects were not "added" to any version of
Python, since they were there from the start.  But even for some
hypothetical python-without-callables, macros are different.  You
-cannot- give a formal EBNF description for the syntax of every
expression that a macro make allowable...  I think that is necessarily
true for a non-trivial macro system.

|       evalone = __macro__(evalone)
|And you'd invoke it as "evalone(pred, expression1(), expression2())".

Yuck.

Yours, Lulu...

--
 mertz@  _/_/_/_/ THIS MESSAGE WAS BROUGHT TO YOU BY: \_\_\_\_    n o
gnosis  _/_/             Postmodern Enterprises            \_\_
.cx    _/_/                                                 \_\_  d o
      _/_/_/ IN A WORLD W/O WALLS, THERE WOULD BE NO GATES \_\_\_ z e





More information about the Python-list mailing list