www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/04/05/22:04:10

From: james archer <snowphoton AT mindspring DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Bracketing: A Matter of Style
Date: Wed, 05 Apr 2000 16:46:05 -0700
Organization: murmur design
Lines: 53
Message-ID: <38EBD03D.895D1680@mindspring.com>
NNTP-Posting-Host: d1.56.cd.18
Mime-Version: 1.0
X-Server-Date: 5 Apr 2000 23:27:03 GMT
X-Mailer: Mozilla 4.7 [en] (Win98; I)
X-Accept-Language: en
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I know this probably puts me in the "weirdo" category, but I have always

coded (and probably always will), with a bracketing style like this:

int main(void)
    {
    printf("Hello, World!");
    return 0;
    }

That seems to me to be the most logical way to do it, for a variety of
reasons:

1) The function is clearly visible, instead of being obscured, because
it is the only thing on the far left.  This may seem trivial, but it
makes it much easier to skim through code looking for a particular
function.
2) All the contents of the function (or loop or whatever) line up, so
that it is easy to tell what is contained in what.
3) It is easy to tell which brackets are unpaired (for those lazy folks
who always forget to close them), because the start and end brackets
line up.
4) The white space helps separate chunks of code and thus make them
easier to understand at a glance.
5) Aesthetically speaking, it produces clearer, better-looking code
(imho).

I realize that most coders are almost religiously against this
bracketing system, and cling instead to the trendier style exemplified
thusly:

int main(void) {
    printf("Hello, World!");
    return 0;
    }

(...or some variation thereof).

This appears much more awkward, and it accomplishes little.  The coders
are saving a single line of whitespace, while losing the aforementioned
benefits of the "lined-up" bracketing style.

Perhaps, of course, I am completely wrong.  If someone would care to
point out the benefits of the predominant bracketing style, I would much

appreciate it.

James

ICQ: 49636524
snowphoton AT mindspring DOT com
http://www.mindspring.com/~snowphoton/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019