Re: Automated indentation - proposal

Marc Wachowitz (mw@ipx2.rz.uni-mannheim.de)
13 May 1994 15:58:33 GMT

Donald Beaudry wrote:
> This proposal comes real close to what I have been thinking about, but
> fails to capture some important details. For instance, what happens
> with else and elif statements?

Oops, I completely overlooked compound statements with multiple parts.

> Any colon that open a block following a compound statement, (if,
> while, for, try, def, class) can be omitted. If the colon is omitted,
> the block must be closed by either an 'else', 'elif', 'except',
> 'finally', or 'end' followed by either 'while', 'for', 'try', 'def',
> or 'class' depending on what statement opened the block.

Hmm, I don't think I'm going to like such a little thing as a colon to
decide about such a big matter.

As I think about it I'm even tempted to propose something very simple:
A code block may begin with the word "begin" and end with "end", which
both must be indented on the same level as the block. The two keywords
may only appear together or both be omitted.

E.g. def compare(a,b):
begin
if debug_flag: print "entering 'compare'" # no block
if a < b:
begin
if debug_flag: print "compare:", a, "is smaller"
return -1
end
elsif a > b:
begin
if debug_flag: print "compare:", b, "is greater"
return 1
end
else:
# no "begin...end" here, trust indentation
if debug_flag: print "compare:", a, "equals", b
return 0
end

Yes, it's a bit wordy, but then it's safe and simple, isn't it? ;-)

------------------------------------------------------------------------------
* wonder everyday * nothing in particular * all is special *
Marc Wachowitz <mw@ipx2.rz.uni-mannheim.de>