Article View: comp.std.c
Article #3895Re: "Canadian style" of indentation
From: mfinney
Date: Thu, 31 Aug 1995 20:27
Date: Thu, 31 Aug 1995 20:27
68 lines
3098 bytes
3098 bytes
In <DE616L.6xq@ns1.nodak.edu>, peppenge@badlands.NoDak.edu (billy the kid) writes:
>In article <41gvsi$hfv@mujibur.inmind.com>, <mfinney@inmind.com> wrote:
>Whatever turns your crank, just be consistant. By that, I mean don't
>consistantly use a different format for every function.
Absolutely true. But most programmers with a little experience
will agree that SOME indentation standard should be followed, but
it doesn't really matter which. Most companies of any size already
impose standards on code, including indentation. So a great many
programmers are already adherring to somebody else's indentation
standard. It doesn't seem to significantly impact the job market,
so far as I can tell.
Given those considerations, requiring that a particular indentation
style be followed for all users of a langauge is not that obnoxious.
Especially when the benefit of doing so is to make code syntax
simpler (to a human) and to reduce the number of bugs. Not to
mention reducing typing! Finding problems such as...
if (aTest)
aStatement1;
else
aStatement2;
aStatement3;
can be VERY difficult because programmer almost always go
by the indentation rather than the braces. And the mismatched
else clause problem ALSO goes away. So if the indentation
is made fundamental rather than the braces, those bugs will
simply disappear.
Further, while there may be a lot of different styles relative
to the braces, there are a lot fewer styles when the braces
are removed. About the only variations that commonly occur
are...
if (anExp)
aStatementBlock
else
aStatementBlock
and...
if (anExp)
aStatementBlock
else
aStatementBlock
So the indentation rule and the one statement per line rule
simply recognizes what good programmers do already, and
with the reduced range of possibilities for the indentation
rules, the rule actually imposed is not that bad.
The reason that that particular rule was chosen, was that
it allows the compiler to generate EXACTLY the necessary
block scope because the dependency rule mirrors the
information that the compiler needs. It should therefore
be reasonably understandable to humans.
And, wait there's more! <GG>, not only did I eliminate
braces and semicolons, but I was also able to eliminate
other parts of the syntax (such as "else if" in a else-if
chain). My tests indicated that those rules resulted in
about a 30% non-white space reduction in a typical
program. Perhaps less today, with longer variable and
function names common.
Michael Lee Finney
Technical Details
Message-ID:
<4255vr$12@mujibur.inmind.com>Path:
arc1-ca.pugleaf.net!mujibur.inmind.com!usenetReferences:
<41g464$6vv@ruby.ucc.nau.edu> <41gvsi$hfv@mujibur.inmind.com> <DE616L.6xq@ns1.nodak.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!mujibur.inmind.com!usenet From: mfinney@inmind.com Newsgroups: comp.std.c Subject: Re: "Canadian style" of indentation Date: 31 Aug 1995 20:27:39 GMT Organization: In Mind, Inc. Message-ID: <4255vr$12@mujibur.inmind.com> References: <41g464$6vv@ruby.ucc.nau.edu> <41gvsi$hfv@mujibur.inmind.com> <DE616L.6xq@ns1.nodak.edu> Reply-To: mfinney@inmind.com NNTP-Posting-Host: finneyman.inmind.com X-Newsreader: IBM NewsReader/2 v1.2