Fully Bracketed Syntax

Mike Steed MSteed at altiris.com
Thu Feb 10 17:32:42 EST 2000


> From: Eaglestone, Robert [NGC:B918:EXCH]
> [mailto:eaglesto at americasm01.nt.com]
> Sent: Thursday, February 10, 2000 3:13 PM
> To: python-list at python.org
> Subject: Fully Bracketed Syntax
> 
> 
> Hello all,
[...]
>
> if ( foo > bar )
>    do_something();
>    do_something_else();
>    done();
> endif
[...] 
> I guess what I'd like is some clear reasoning about
> bracketing and indenting that warrants such a feature 
> of a language.

In his book Code Complete, Steve McConnell calls this syntax "pure blocks".
Ada is the only language he mentions that implements this.  (Didn't Modula-2
do this too?)  One of McConnell's rules is that the visual layout of the
code should reflect its logical structure in order to maximize readability.
In your example, the three lines inside the if should be indented (as they
are) to indicate that they are suborinate to the conditional.  McConnell
likes pure block syntax best because it lends itself more readily to this
style than begin..end and {..}.

In this sense, Python is even better, because the layout of (valid) code
always corresponds to its structure.  (That is, if you ignore the one-line
form "if a: blah".)

--
M.




More information about the Python-list mailing list