Re: multi-line expressions

Tim Peters (tim@ksr.com)
Fri, 25 Feb 94 01:22:58 EST

Random observations:

The near-universal experience is that Python newcomers hate Python's
indentation, but grow to love it.

Learning how to use python-mode in Emacs is well worth the effort, but
indentation-based blocking is novel enough to most newcomers that
python-mode seems, at first, just to confuse them more (it's "not like"
other language modes, and can't be, because it doesn't have blocking
brackets to search for). Indentation is Python's "bridge of asses" in
more ways than one <wink>.

CWI blesses the world with another nice language, called ABC, which
predates Python and which also uses (only) indentation for blocking.
Interactive command processing is an integral part of ABC, and it
automatically suggests indentation (like python-mode does in Emacs) when
it's ready to accept a new line from you. I suspect, but do not know,
that Guido implicitly or explicitly hoped to get around to doing the same
kind of thing for Python. I believe there's some truth to the
speculation that getting a strong Emacs mode worked against that
happening.

Curly braces {} are already used in Python (to construct dictionaries).
If they were overloaded to denote blocking too, then e.g.

if something: {}

would be at best confusing (well, I admit it's confusing now -- but it
_is_ a legitimate Python statement now). In fact, to disambiguate
blocking-vs-dict-constructor in all cases would require unbounded
lookahead in the parser, a major No-No in a language with exquisitely
clean syntax (this ain't C++ <0.5 grin>). Ditto for square brackets.

These ASCII characters are still unused in Python: @ $ ?
That's it.

I agree it would be nice to have a non-indentation-based alternative.
Partly to make it easier to suck in newcomers, and partly to make it
easier to construct code to pass to eval. But I can live happily without
it.

If the language does support a new method, python-mode will not recognize
it unless you teach it how to. Did that sound like a petulant threat?
Na -- just saying that's more work than I can make time for -- especially
for something I can live without <grin>.

if-god-didn't-intend-for-us-to-use-indentation-why-did-he-fill-our-
minds-with-blanks?-ly y'rs - tim

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