Re: [RFC] Draft Proposal for New Python Syntax

Tim Peters (tim@ksr.com)
Thu, 26 May 94 00:45:39 -0400

> [kenneth]
> ...
> (1) Function - is there some important semantic capability that
> cannot be concisely expressed in the current syntax, but that would
> be concisely expressable in the (a) new one?

As a self-confessed Lisp'er, you're going to find that Python's form of
lambda is _very_ limited. But I bet it won't bother you once you get
comfortable enough to use Python for writing Python <wink>.

> (2) Scaling - Does the current syntax not scale up? Eg, even with
> good modularization, does the indentation wind up forcing wrap
> around the right margin? Or lots of finagling with strings, to
> get them to flow together right without line-wrapping?

People dig their own graves with this stuff. E.g., if I find my nesting
going deeper than 4 or 5 levels, I throw the code out & find a cleaner
design and/or decomposition -- in Python or any other language. BTW, the
Python distribution comes with many Python functions in the library and
demo directories, so take a look!

> (3) Dispersion - Does code wind up being too spread out, so that i
> often cannot comfortably arrange to see a significant portion of a
> function using one 60-line emacs window?

_That_ one's a clear "no!". Partly because OO design tends to make for
small functions and lots of reuse, partly because the syntax _doesn't_
burn lines for block-closers (or openers), and partly because the built-
in data types are high level. E.g., list catentation is an infix "+",
list iteration a plain "for" statement, & so on. You can say a lot in a
few lines.

I just took a peek at the Python library. There are 912 Python
functions; just 2 of them occupy (exclusive of comments and blank lines)
more than 60 lines; the median is 6(!) lines, including the opening
"def".

BTW, most Emacs users aren't aware of its `C-x $' command (`set-
selective-display'). It's very handy in Python, _because_ of the
indentation-based syntax. Give it a try! Great way to get a quick
overview of the classes & methods in a module.

> ...
> seems like python keeps the lexical scoping to two levels, and i
> haven't heard complaints about that. ??

Na, you just haven't been tuned in long enough <grin>. Such complaints
never last long, though -- functions tend to be so small, and modules and
classes so easy to create and use, that once the One True Python Style is
adopted you just lose interest.

> ... I am inclined to think that less is better, when packing code.

Simple statements _can_ be crammed onto one line in Python today, by
separating them with semicolons, and e.g.

a, b, c = 1, 2, 3

does what you think it does. I abused both of those at first, but
quickly stopped. BTW, the latter gimmick has many _reasonable_ uses too,
as in

x, y = y, x # swap values

which is both shorter & clearer than the equally legal

temp = x; x = y; y = temp

But you should consider asking a loved one to shoot you if you starting
doing stuff like

left, (i, j), x[i], N = left+N, tupleize(x[j]), right-N, N-ofs

better-a-loved-one-than-us<wink>-ly y'rs - tim

Tim Peters tim@ksr.com
not speaking for Kendall Square Research Corp