Steven D'Aprano <[EMAIL PROTECTED]> writes: > Now, if you want to tell me that, despite all the talk, Lisp coders don't > actually create new syntax or mini-languages all that often, that they > just use macros as functions, then the question becomes: why do you need > macros then if you are just using them as functions? Why not use functions?
Macros let you write what amounts to functions that don't evaluate their arguments. Think of the endless clpy wars over the ternary conditional operator. You want to write something like def ternary(test, iftrue, iffalse): if test: return iftrue else iffalse but because of side effects, you don't want a = cond(test, f(x), g(x)) to evaluate both f and g. That is trivial to do with a macro but can't be done with a function. Macros can be used tastefully and effectively in Lisp programs, though not everyone limits their usage like that. Haskell uses a different approach: 1) all arguments are unevaluated unless the program tries to actually use the values. 2) there are no side effects anyway. This may be why Haskell's current lack of macros apparently isn't a big problem. -- http://mail.python.org/mailman/listinfo/python-list