Is Python really "Lisp without parentheses"? So would it be easy to *implement* a lot of Python in Scheme/Lisp?

Devin Jeanpierre jeanpierreda at gmail.com
Fri Jan 3 12:10:07 EST 2014


On Thu, Jan 2, 2014 at 10:46 PM, Chris Seberino <cseberino at gmail.com> wrote:
> I've heard it said, by no less a guru than Peter Norvig, that Python is a lot like Lisp without the parentheses.... at least for the basics of Python.

There are plenty of non-superficial differences. Python has lexical
scope, lisps usually have dynamic scope. Python has statements and
expressions, lisps have expressions and maybe only a few tiny extra
restrictions. Python has dynamic dispatch everywhere, lisps have it
usually almost nowhere. And the unifying thing that makes a lisp a
lisp is macros, which Python lacks.

> For pedagogical reasons, I'm wondering if it would be easy to implement a big subset of Python in Scheme.

A lecturer of mine back in university did this (implemented a subset
of Python in Racket). My understanding is that this is primarily
interesting to show that Racket is not as crazily different as it
looks from the syntax.

When I TA'd for him, he had a really neat lecture where he gave the
following three snippets of code:

// C++
Foo x = y;
x.bar = 3;

// Java
Foo x = y;
x.bar = 3;

// Scheme
(define x y)
(foo-bar x 3)

The syntax of the first two is identical, so the uneducated would
assume they do the same thing. But actually, the latter two are the
ones with the identical behaviour. It is definitely true that the
syntax differences hide how similar Scheme and Python are. These two
languages are close enough together that any

> The basics of Scheme or Lisp are amazingly easy to implement.  Would implementing a subset of Python in a Scheme subset be a clever way to easily implement a lot of Python?

If it's easy to implement in terms of Scheme, which is itself easy to
implement, then it would be easy to implement directly, so this
doesn't seem like a useful question to ask. Anyway, most of the useful
bits of Python aren't present or have different semantics than how
they work in lisps.

-- Devin



More information about the Python-list mailing list