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

Message-ID: <38EBFBD7.7D03CB96@hotmail.com>
From: Andrew Hakman <hakmana AT hotmail DOT com>
X-Mailer: Mozilla 4.72 [en] (Windows NT 5.0; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Bracketing: A Matter of Style
References: <38EBD03D DOT 895D1680 AT mindspring DOT com>
Lines: 77
Date: Thu, 06 Apr 2000 02:55:05 GMT
NNTP-Posting-Host: 142.13.16.203
X-Trace: typhoon.mbnet.mb.ca 954989705 142.13.16.203 (Wed, 05 Apr 2000 21:55:05 CDT)
NNTP-Posting-Date: Wed, 05 Apr 2000 21:55:05 CDT
Organization: MBnet Networking Inc.
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I would have to agree with this. Since I started programming in c++ (in
DJGPP right from the start!) 2 years ago, I was introduced to both
bracketing styles, and liked the "lined up bracket" style right off the bat,
only I usually do mine like this:
int main(void)
{
    printf("Hello, World!");
    return 0;
}

you can tell where functions, loops, etc. end and eliminates the need for

       }   //end of whatever - this comment I see in other people's code all
the time because there final closing bracket doesn't line up with their
function, and they can't figure out what it is closing otherwise.  Another
thing I hate (hope I'm not stepping on too many toes here) is using TABs for
indents. For quite compact, yet very readable code I tend to use 2 spaces
for indents.

Guess it really comes down to personal preference!
Andrew

james archer wrote:

> 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