Python's Lisp heritage

James J. Besemer jb at cascade-sys.com
Sat Apr 20 06:41:01 EDT 2002


Andrew <dalke at dalkescientific.com> replies:

> As I understand it, Python's Lisp heritage is pretty indirect.
> The most direct one I know of is docstrings, based on a similar
> feature in elisp.

Although they may be found in clisp, I don't think docstrings are regarded a general feature of "Lisp" or Scheme.

Seems to me the more prominent genetic similarities are the overall semantics: late binding, garbage collection, lists and sequences as a way of life.  Also, the fact that functions are values that may be free rebound to other names.  The semantics of and/or are rarely
encountered outside of lisp and derivatives.  MAP, APPLY, and especially LAMBDA also are pretty unique to Lisp.  This is VERY like Lisp and very UNLIKE "Algol like" languages.

I suppose Moshe Zadka is more accurate about the actual history without contradicting the point I was trying to make (that there are some strong similarities):

    Python and Scheme are very similar languages,
        that came from very different backgrounds.

Perhaps some of the Lisp heritage slipped in via ABC or via proposals from others without Guido's knowledge.

> If there was lisp heritage, why isn't there anything like car/cdr?

Easy.  Some things got left out.  They're not the SAME language.

List indexing and and slices are better and more powerful, an important step forward.

Note that CAR and CDR stand for Contents Address Register and Contents Data Register.  The original Lisp implementation (before some of you were born) was very specific to the IBM 709X architecture, in which it was easy to pack two addresses into a single word (with a
few bits to spare).  The more important LANGUAGE abstraction is that dotted pairs can be formed into lists and lists may be manipulated at a higher levels, and this same abstraction exists in Python.

> To back up my statement, here's some quotes from Guido I found in
> the Google usenet archives (no URLs since the Google links are too
> long)
> ] Also, the Python docs (to the extent that I wrote them)
> ] *never* attribute *anything* to Scheme or Lisp.  Python comes from the
> ] Algol family of languages.

In syntax yes.  In semantics it seems quite the opposite.

> ] (I'm a rabid Lisp-hater -- syntax-wise, not semantics-wise! -- and
> ] excessive parentheses in syntax annoy me.  Don't ever write return(i)
> ] or if(x==y): in your Python code! :-)

I hate Perl but I am well acquainted with how it works.  I agree excessive parentheses can be a bad thing.

> ] Common Lisp and Scheme.
> ]
> ] These languages are close to Python in their dynamic semantics,

Which was my point.

> but so
> ] different in their approach to syntax that a comparison becomes almost
> ] a religious argument: is Lisp's lack of syntax an advantage or a
> ] disadvantage?

I don't agree.  I think syntax and semantics are almost orthogonal, with syntax being the less complicated, less important of the two.  The fact that Python and Scheme have similar semantics make them very similar despite dramatic differences in their outer appearance.

Other than that, I think it's widely acknowledged that Lisp's lack of syntax is a disadvantage for most applications.  The exception might be the AI sub-domain of "program understanding," a tiny niche indeed.

> ] My conjecture: writing lambdas in Python is a bad habit, brought on
> ] from exposure to Lisp or Scheme.  Most Python code looks better after
> ] rewriting without lambdas.

How'd it get in there in the first place?  MAP?  APPLY? EVAL?  They're not in ABC or any other "Algol language" that I'm aware of.  There's nothing you can do with them in Python that you can't accomplish some other way (albiet with having to perhaps introduce
auxilliary control structures and temporary variables).

> There's also a relevant quote from Tim Peters:
> ] The problem Python set out to solve is that ABC was useless for
> ] real-life programming.  If Guido knows anything substantial about
> ] Lisp or Scheme, he's done an excellent job of hiding it for more
> ] than a decade.  I've seen him struggle with simple elisp, for God's
> ] sake <wink>.
>

I thought I read an essay of Guido's once long ago where he acknowledged a lisp heritage but I now see that I was mistaken.

And since I was mistaken about the historical asides, my suggestions about inline choice and len() are blithely ignored.

--jb

--
James J. Besemer  503-280-0838 voice
http://cascade-sys.com  503-280-0375 fax
mailto:jb at cascade-sys.com







More information about the Python-list mailing list