Python syntax in Lisp and Scheme

David Mertz mertz at gnosis.cx
Thu Oct 9 03:20:24 EDT 2003


"Doug Tolton" <dtolton at yahoo.com> wrote
|This is what I don't understand.  Macros truly do not *change* the
|language.  Sure they make a higher level abstraction that sits on top of
|the language, but the underlying language is still the same.

The thing is, to me--and I know to a lot of programmers--syntax matters.
In fact, it matters so vicerally that I have trouble taking at face
value those folks--usually coming from the Lisp community--who say with
great sincerity that it's just surface, and ignorable.  But I should
accept those testimonies... different people are probably wired
differently in some pretty major ways.

Now, for example, CL macros are powerful enough to create a "Python
environment."  It would take some work to do this, but obviously, CL is
powerful enough to do everything Python does, even in more than the
Turing completeness sense.  Imagine a Python enviornment, kinda like the
infix environment:  You write a complete Python program (I suppose with
an extra left paren and word at the start, but straight Python up to the
closing paren), and then run it in CL.

If you want to claim that macros -do not change the language-, then you
have to accept that the Python language, whitespace, infix, namespace
rules, and all the rest, is NOT A CHANGE from Lisp.  Of course, you
could also write a CL interpreter in Python... but that's a different
thing, presumably it would not transform the source into Python (at
compile time), but rather emulate each needed action.

Btw. I *do* see some dangers in metaclasses too.  I know a little bit
about them--if you do a search for "metaclass" in google, the first five
hits are all links to articles by me (not quite so high if you
pluralize... go figure).  But I'm starting to get worried about their
use in Python.  I see more and more suggestions on c.l.py about novel
uses that really scare me... largely because I need to read them four or
five times before I can understand what they do, and even then I don't
become 100% sure there isn't some glitch in there.

I kinda liked things better not so many months back when most
Pythonistas had brain-melt when they saw metaclasses, and would hardly
think of writing them themselves (but maybe just using someone else's as
a kind of "mix-in" or "aspect oriented" technique).  I don't really want
to have to maintain code with overly clever use of metaclasses, and the
reason is pretty similar to the reason folks like Alex and Laura have
reservations about macros.  It's not quite changing the syntax, but
significant semantic aspects can change in hard-to-locate ways.

On the other hand, HOF's don't bother me the same way.  Some of them can
be hard to reason about, sure.  But they never seem to operate "behind
the scenes" in the same way.  You know when a HOF is doing its thing,
even if you're not entirely confident about what that thing is... and in
that respect it's not much different from a regular function/method
call.

Yours, David...

--
Keeping medicines from the bloodstreams of the sick; food from the bellies
of the hungry; books from the hands of the uneducated; technology from the
underdeveloped; and putting advocates of freedom in prisons.  Intellectual
property is to the 21st century what the slave trade was to the 16th.





More information about the Python-list mailing list