Steven D'Aprano schrieb: > On Sat, 09 Dec 2006 22:41:12 -0500, Ken Tilton wrote: > >>> I know that. It was more of a rhetorical question -- Lispers are either >>> trying to emphasis the radical nature of what you can do with macros, or >>> understate it and make them seem just like functions. >> Yep, both. The first is rare. CLOS is one, my Cells (ported this summer >> to PyCells as part of SoC 2006) is another. The latter is the norm. > > If macros' advanced usage is rare, and most usage of macros could be done > by functions, then maybe that explains why so many coders don't miss them.
You can't do with functions what you can do with macros. Macros are just parameterized code. A template. Compare it with HTML templates <html> <body> Your name is <?py print name.getUser(loggedInUser) ?>.<br> Welcome! </body> </html> The page that arrives the user does not include any template code anymore. Just plain html. Same happens with Lisp macros. After compilation (preprocessing the html template by Zope) there are no macros left. So in the end you have just some Lisp functions. So one does not *need* macros, in the sense of turing completeness. But at the same time one can meet lots of places where templates can make sense and where they are used. Even the programmers of Zope thought of them as a plus for productivity. In Lisp you don't always design one huge macro after the other, which really saves a lot of code. Many macros save one or two short lines of code. This might sound not important. But it sums up. Somewhere else I asked you to imagine how you would like it if you had to call doodleBoodle() before each if-statement to make it work. That would be plain stupid if you had to. So if you meet something in code that you use several times, then you factor that repeating block of code out into a function that takes another function which will get called in the right environment. And macros help here "only" to save one or two loc. But as I said, it sums up. André -- -- http://mail.python.org/mailman/listinfo/python-list