For Kenny Tilton: Why do I need macros revisited.

Michele Simionato mis6 at pitt.edu
Sat Aug 23 03:33:52 EDT 2003


Kenny Tilton <ktilton at nyc.rr.com> wrote in message news:<3F45A7BF.4060806 at nyc.rr.com>...
> You are absolutely right. Metaclasses are killer. I am surprised 
> Pythonistas afraid of macros let them into the language! 

Me too. Actually they are quite *scaring*. In my post on 
"PEP 312 (and thus 308) implemented with a black magic trick" actually
I argued that they were much *worse* than macros, since they are able
to change the *semantics* of the language, a much more dangerous
thing than simply changing the syntax. In a sense, they are deeply
unpythonic,
the exact opposite of "explicit is better than implicit". 
Maybe it enters in "practicality beats purity", but this is stretching
the principle quite a bit. Same for descriptors and properties, which
still are much less dangerous.
I think metaclasses were intended not to be used, except from
developers
and very advanced users. The problem is that once you have a feature
in
a language, people will use it. I do like metaclasses, but I would be
scared
in debugging a large program written by others using them and with
poor ocumentation. Each time you see a class, you are never sure of
what it is
doing; when the bug happens, you are not sure if it is in the class or
in
the metaclass (this happened to me even with my own programs). 
It is quite worrysome, actually. Fortunately, we are good people, here
on c.l.py, and I don't think anybody would mess things up, but it
could
*easily* be done. 
Now, I trust the programmer and I do like the power and the freedom;
but still it strikes to me as a case of multiple personality to have
a language that at the surface is plain, clear, nicely indented, and
under the cover ... caveat emptor!

Let it be this way, anyway, and let us continue to advertise it as 
a "clean" language. Let us stop people who want case statement, repeat
.. until, ternary operators, braces, and the like, and let us under
the cover give people the freedom to program classes and altering at
will nearly everything at the semantics level. Let the other worry
about syntax ...

   ;-)
 

> I actually had 
> a metaclass implementation of Cells until I decided to release the 
> source. The MOP is not part of the standard, and it shows across 
> implementations. Hell, MCL does not even expose a MOP.
> 

Quite impressive. You are actually saying that you do prefer Python
over
Lisp on a problem of ultra-high level programming which should be
the rightful Lisp playhouse ... To be fair, the reason is not lack of
power by Lisp, but lack of standardization, still it is something that
makes me thinking ...

Michele Simionato, Ph. D.
MicheleSimionato at libero.it
http://www.phyast.pitt.edu/~micheles
--- Currently looking for a job ---




More information about the Python-list mailing list