Automated indentation

George Reynolds (george@vicorp.com)
Fri, 6 May 94 15:19:13 EDT

I have been using python off and on for a few months, almost
constantly for the last couple of months writing a C++ code generator
for binding python to a large C++ class lib.

My experience with the indentation based scheme is not unrelated to
others (as I found by reading through the mail archive) that at first
its very annoying and then one learns to like it. I definitely found
this to be true AT FIRST. But, as the program expanded and evolved, my
annoyance returned and now I find it to be a very serious flaw in
python's usability. (I did read Guido's recent message trying to
justify this scheme...sorry I dont buy your argument.)

This is a serious problem since Python is in most other respects
a fantastic language which I am recommending to all my friends
and associates.

As a program is evolving (as opposed to simply reading the code) one
is often cutting, pasting and otherwise modifying code quite
frequently. My experience is that I am constantly annoyed at having to
re-indent every line when the indentation could be automated since I
already did it correctly once.

Also, mistakes do happen. For example when using python-mode in emacs,
I hit tab on a line by mistake and that line gets indented 5 levels.
Where was it originally? Impossible to know unless I stop and grok the
meaining of the function... again.

Thus the issue is that indentation can be automated if desired.

Suggestion:
1. Optionally allow replacement of the ':' after control
statements with 'do' (or another reasonable word)
2. If 'do' is used insted of ':' the statement block is
terminated with 'end <keyword>' indented at the level of
the control word.
3. Not indenting the delimited block would yield a syntax error.

NOTE: This would be optional. If someone wants the current version
fine, if someone wants the proposed version, ok. Thus automated
indentation is possible if desired.

For example:

Current Python:
--------------
def rotateAll( param1, param2 ):
List = param1
blah
blah
blah
for item in List:
blah
blah
blah
blah

Proposed Python:
---------------
def rotateAll( param1, param2 ) is
List = param1
blah
blah
blah
for item in List do
blah
blah
end for
blah
blah
end def

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ George Reynolds +
+ VI Corporation +
+ 47 Pleasant St +
+ Northampton MA 01060 +
+ +
+ george@vicorp.com "You can't count on consistency" +
+ 413-586-4144 X Toolkit Intrinsics Programming +
+ Manual, page 245. +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++