What can you do in LISP that you can't do in Python

Nonexistence huaiyuan at rac2.wam.umd.edu
Tue May 15 00:03:41 EDT 2001


claird at starbase.neosoft.com (Cameron Laird) writes:

> I have a pet belief that hygienic macros as practiced
> in Lisp are somewhat overdone (I know my own fondness
> for extreme factorization), and of material interest
> largely for a single category of use:  "self-modifying"
> code which amounts to initialized method definition.
> Exactly the same calculations are available in a purely
> run-time formulation, withOUT macro funniness, but at
> the cost of more run-time calculation.

Self-modifying code is cute, but it has nothing to do with Common Lisp's
macro.  "Code transformation" or "code generation" might be a more accurate
characterisation of the macro facilities in CL.  As opposed to
self-modifying code, which is largely black magic, code-transformation is
well-defined and well-understood.

> Until I have more evidence to the contrary, I expect
> correct macro usage to be a performance optimization.

Using macro for performance is considered bad karma among seasoned CLers.
They'd use INLINE declarations for functions instead in cases where
performance can be improved by macro subsititutions.

IMHO, the point of macro is to let the programmers say more with less.  
(So if you replace "performance" with "programmers' performance", I might
agree with you :).  CL is the only language in which I've never felt the
need to repeat myself when telling the stupid computer what to do.

Of course, like anything else, you can use macro to shoot yourself in the
foot; but judicious use of macro can lead to more concise, understandable,
and maintainable code -- simply because there is less to understand and
maintain.

- yuan



More information about the Python-list mailing list