Related articles |
---|
Programming language and IDE design martin@gkc.org.uk (Martin Ward) (2013-10-17) |
Re: Programming language and IDE design bc@freeuk.com (BartC) (2013-10-19) |
Re: Programming language and IDE design DrDiettrich1@aol.com (Hans-Peter Diettrich) (2013-10-20) |
Re: Programming language and IDE design genew@telus.net (Gene Wirchenko) (2013-10-20) |
Re: Programming language and IDE design genew@telus.net (Gene Wirchenko) (2013-10-21) |
Re: Programming language and IDE design gneuner2@comcast.net (George Neuner) (2013-10-22) |
Re: Programming language and IDE design DrDiettrich1@aol.com (Hans-Peter Diettrich) (2013-10-23) |
Re: Programming language and IDE design wclodius@earthlink.net (2013-10-22) |
[20 later articles] |
From: | "BartC" <bc@freeuk.com> |
Newsgroups: | comp.compilers |
Date: | Sat, 19 Oct 2013 22:05:23 +0100 |
Organization: | virginmedia.com |
References: | 13-10-016 |
Keywords: | design, comment |
Posted-Date: | 20 Oct 2013 00:14:14 EDT |
"Martin Ward" <martin@gkc.org.uk> wrote in message
> (3) Indentation helps the reader if it is consistent: so should also
> be enforced by the compiler. In line with point (2), nesting should
> be defined by *both* indentation *and* grouping keywords:
> with the compiler enforcing consistency between the representations.
> This means that the reader can rely on either indication of nesting,
> since both are reliable.
> [On the other hand, having recently written a lot of python code, I've
> come around to the opinion that enforced indentation is all the grouping
> you need. -John]
Grouping provides useful extra redundancy and inspires more confidence in
the reader of the code. Example:
s1 # statement 1
if cond:
s2
s3
s4
s5
s6
An accidental press of Delete before s4 removes the tab (although I've used
spaces for usenet purposes. And if usenet has also eaten those spaces, then
s2, s3 and s4 should be indented). Now the code still compiles, but doesn't
do the same thing:
s1
if cond:
s2
s3
s4
s5
s6
Compare with a version using begin-end grouping:
s1
if cond then
s2
s3
s4
end if
s5
s6
It still works correctly whether there's a tab in front of s4 or not. The
presence of the 'end if' reinforces that belief that s4 is part of the
conditional block.
Transmission often removes tabs, or mixes up tabs and spaces, or removes
what it thinks is superfluous white space altogether.
--
Bartc
[Chacun
a
son
gout
-John]
Return to the
comp.compilers page.
Search the
comp.compilers archives again.