Michael Chermside wrote:
Jim Jewett writes:The typical argument in defense of macros is that macros are just like functions, you go to the definition
As best I can tell, the anonymous blocks are used to take
care of boilerplate code without changing the scope -- exactly
what macros are used for.
Folks, I think that Jim is onto something here.
I've been following this conversation, and it sounds to me as if we are stumbling about in the dark, trying to feel our way toward something very useful and powerful. I think Jim is right, what we're feeling our way toward is macros.
The problem, of course, is that Guido (and others!) are on record as being opposed to adding macros to Python. (Even "good" macros... think lisp, not cpp.) I am not quite sure that I am convinced by the argument, but let me see if I can present it:
Allowing macros in Python would enable individual programmers or groups to easily invent their own "syntax". Eventually, there would develop a large number of different Python "dialects" (as some claim has happened in the Lisp community) each dependent on macros the others lack. The most important casualty would be Python's great *readability*.
(If this is a strawman argument, i.e. if you know of a better reason
for keeping macros OUT of Python please speak up. Like I said, I've
never been completely convinced of it myself.)
and see what they does.
But depending on how much variation they offer over the normal grammar even eye parsing them may be difficult.
They make it easy to mix to code that is evaluated immediately and code that will be evalutated, maybe even repeatedely, later, each
macro having its own rules about this. In most cases the only way to discern this and know what is what is indeed looking at the macro definition.
You can get flame wars about whether introducing slightly different variations of if is warranted. <.5 wink>
My personal impression is that average macro definitions (I'm thinking about Common Lisp or Dylan and similar) are much less
readable that average function definitions. Reading On Lisp may give an idea about this. That means that introducing macros in Python, because of the importance that readability has in Python, would need a serious design effort to make the macro definitions themself readable. I think that's a challenging design problem.
Also agree about the technical issues that Guido cited about referencing and when macros definition enter in effect etc.
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com