Python syntax in Lisp and Scheme

Eli Barzilay eli at barzilay.org
Tue Oct 7 17:28:02 EDT 2003


Matthias Blume <find at my.address.elsewhere> writes:

> raffael at mediaone.net (Raffael Cavallaro) writes:
> 
> > Two words: code duplication.
> 
> Three words and a hyphen: Higher-Order Functions.

This covers most usages of macros for control structures, but not
all.  (For example, goto.)

But there is an additional word to add, no hyphens: Bindings.


> > This can only be accomplished with functions if you're willing to
> > write a set of functions that defer evaluation, by, say parsing
> > input, massaging it appropriately, and then passing it to the
> > compiler. At that point, however, you've just written your own
> > macro system, and invoked Greenspun's 10th Law.
> 
> This is false.  Writing your own macro expander is not necessary for
> getting the effect.  The only thing that macros give you in this
> regard is the ability to hide the lambda-suspensions.  To some
> people this is more of a disadvantage than an advantage because,
> when not done in a very carefully controlled manner, it ends up
> obscuring the logic of the code.  (Yes, yes, yes, now someone will
> jump in an tell me that it can make code less obscure by "canning"
> certain common idioms.  True, but only when not overdone.)

(This hits one of the major differences between Lisp and Scheme -- in
Lisp I'm not as happy to use HOFs because of the different syntax
(which is an indication of a different mindset, which leads to
performance being optimized for a certain style).  Scheme is much more
functional in this respect, for example -- using HOF versions of
with-... compared to Lisp where these are always macros.)

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!




More information about the Python-list mailing list