Python syntax in Lisp and Scheme

Thomas F. Burdick tfb at famine.OCF.Berkeley.EDU
Thu Oct 9 15:23:34 EDT 2003


Alex Martelli <aleax at aleax.it> writes:

> Kenny Tilton wrote:
> 
> > Alex Martelli wrote:
> >> ... I do believe that the
> >> divergence problem has more to do with human nature and sociology, and
> >> that putting in a language features that encourage groups and subgroups
> >> of users to diverge that language ....
> > 
> > Can someone write a nifty Python hack to figure out how many times
> > Lispniks have tried to get Alex to explain how macros are any different
> > than high-order functions or new classes when it comes to The Divergence
> > Problem? I love that we have given it a name, by the way.
> 
> The very 'feature' that was touted by Erann Gat as macros' killer advantage
> in the WITH-CONDITION-MAINTAINED example he posted is the crucial
> difference: functions (HO or not) and classes only group some existing code
> and data; macros can generate new code based on examining, and presumably to
> some level *understanding*, a LOT of very deep things about the code 
> arguments they're given.

Yes!  Macros can generate code, and compiler-macros can transform
perfectly ordinary, easy-to-read code into efficient code.  Anyone who
has worked in a domain where efficiency matters has run into the
problem most languages have: abstraction *or* efficiency.  Custom,
domain-specific transforms are something you can't always expect the
compiler to do.  With Lisp, you're not at the mercy of your vendor; if
you know damn well that some readable code A can be transformed into
equivalent, but efficient code B, you can cause it to happen!

>  If all you do with your macros is what you could do with HOF's,

But you can do more with macros, so there's no point in looking at the
conclusion to this sentance.

> Oh, and if you're one of those who disapprove of Gat's example feel free
> to say so, but until I hear a substantial majority denouncing it as idiotic 
> (and I haven't seen anywhere near this intensity of disapproval for it from 
> your camp)

Of course not, it's a lovely example of one use of macros.

> I'm quite justifyied in taking it as THE canonical example of a
> macro doing something that is clearly outside the purview of normal
> tools such as functions and classes.

No, you're not justified at all.

-- 
           /|_     .-----------------------.                        
         ,'  .\  / | No to Imperialist war |                        
     ,--'    _,'   | Wage class war!       |                        
    /       /      `-----------------------'                        
   (   -.  |                               
   |     ) |                               
  (`-.  '--.)                              
   `. )----'                               




More information about the Python-list mailing list