This seems as good a time as any to point out a problem I see with
Python. While most Python programmers seem to like the use of
indentation to show nesting, almost without fail the first thing
people complain about when I show them Python is this reliance on
indentation. I've also seen at least one complaint in some newsgroup
as well.
Personally, although I liked it at first, I've come to see it as a
mixed blessing. My biggest problem is when you jump up several nesting
levels at the end of a block. Without a "}" or "end" it's hard to tell
just what level you're returning to. It's also makes editing in emacs
harder as there's nothing for it to latch on to when doing
auto-indenting.
Sure, you can throw an "# end if" comment in to keep track of the
level, but if you're going to do that, why not have something that has
meaning to Python (and emacs).
What I'd like is an _optional_ bracketing construct, so Steven's
statement could be written as:
>>>for x in list: begin if x[:len(key)] == key : print x; end
Within the bracketing construct indentation is no longer significant.
Outside everthing between begin and end is treated as a single
statement.
I'm not sure whether indentation mode could be able to be turned on
again inside the block. For example:
for x in list: begin if x[:len(key)] == key :
print x
print key
end
Since there is no "begin" after the "if" statement perhaps a change of
indentation can become significant. Except I'm not sure how you return
to indentation-insensitive mode.
Chris
-----------------------------------------------------------------------------
Chris Hoffmann VI Corporation
choffman@vicorp.com 47 Pleasant St. Northampton MA 01060