Fully Bracketed Syntax

Neel Krishnaswami neelk at brick.cswv.com
Thu Feb 10 19:17:17 EST 2000


Mike Steed <MSteed at altiris.com> wrote:
> Eaglestone, Robert [NGC:B918:EXCH] wrote:
> [...]
> >
> > if ( foo > bar )
> >    do_something();
> >    do_something_else();
> >    done();
> > endif
> [...] 
> 
> 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?)

Dylan uses this style, but Modula-2 uses the Pascal BEGIN/END style.

Now to break a trend, and supply some real numbers (this is a slightly
edited version of a post I've made before -- I'd be willing to submit
it to the FAQ...):

-*-*-*-

My other language-of-choice, Dylan, has a syntax and level of
expressive power very similar to Python's, except that it has "end"
block delimiters.

The Gwydion Dylan compiler is about 56,000 lines of non-comment
non-blank lines. Of these 56 KLOC, 8700 contain only "end" statements.
That's about 16% of the code, or 1 line in 6. So we may presume that a
similar fraction of Python code would be "end" statements if Python
had block delimiters, too.

It's also well-known that the average time to debug a function or
class goes up with length, with a sharp upwards kink when the length
of the program object exceeds 1 screenful, whatever the screen size
is.

Let's suppose that we are editing on a terminal that has 42 horizontal
lines (like my XEmacs window). Then adding block delimiters to Python
would mean that the effective screen size would shrink from 42
currently to 35 plus delimiters. This is a painful loss, considering
that the debug time kinks upward whenever a program exceeds one
screenful in size.  Consequently, I think GvR made an excellent choice
in keeping block delimiters out of Python. The gain in readability is
well worth the slight inconvenience of dealing with tabs.

(BTW, I also think Dylan did the right thing, because the block
delimiters in Dylan are mostly there to make it possible to have a
hygienic macro facility. Since Python doesn't have this, it doesn't
need gratuitous "end" statements.)

-*-*-*-


Neel



More information about the Python-list mailing list