Python syntax in Lisp and Scheme

Lulu of the Lotus-Eaters mertz at gnosis.cx
Mon Oct 13 15:35:24 EDT 2003


"Daniel P. M. Silva" <dsilva at ccs.neu.edu> wrote previously:
|Don't fear code that rewrites code.  Hell, if Psycho didn't exist (or if I
|didn't think it did a good enough job), I'd sure like to say:
|optimized:
|  for x in range(2**63):
|     pass
|and let an 'optimized' special form rewrite my code into just "pass".

This really gets at exactly why folks like Alex (and me, perhaps less
emphatically) don't want special forms.  This change in syntax is
mysterious in a different--and usually more dangerous way--than a
function call that can do the same thing.[*]

For example, if you like the name optimized, you can easily write:

    from psyco import bind as optimized
    def silly_loop():
        for x in range(2**63): pass
    optimized(silly_loop)

The intention is equally clear, and the syntax only slightly different.
But in the existing case, it is unambiguous that 'optimized()' is a
ordinary function that happens to take another function object as an
argument.  Of course, you can only do this with function object, since
Python does not (yet) have codeblock objects, but that's of little
significance in practice.

Now obviously, just having this uniform syntax doesn't guarantee
correctness or safety.  Functions can have side effects; and one would
pretty much expect the function to do something with its argument, like
mutating it in some manner.  But at least if I am handed this code, I
don't have the extra burden of trying to guess what a novel syntactic
form is meant to represent.

Yours, Lulu...

[*] I'm not certain whether the current Psyco will entirely
optimize-away the loop.  I think so.  But the point is that is -could-
in principle.

P.S. I REALLY wish many of the Lisp enthusiasts would stop being so
disingenuous about claiming that new syntax is no different from new
functions.  The claim that new syntax is often an overall benefit is
very reasonable (but perhaps wrong).  But the claim that there is no
difference between the above forms is like that of a child who sticks
its fingers in its ears, and chants, "la, la, la, I can't hear you."

--
mertz@  | The specter of free information is haunting the `Net!  All the
gnosis  | powers of IP- and crypto-tyranny have entered into an unholy
.cx     | alliance...ideas have nothing to lose but their chains.  Unite
        | against "intellectual property" and anti-privacy regimes!
-------------------------------------------------------------------------






More information about the Python-list mailing list