Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > matching { } syntax style

Reply
Thread Tools

matching { } syntax style

 
 
bart
Guest
Posts: n/a
 
      10-10-2003
Why is it that everybody likes the follwowing curly braces syntax

function() {
implementations;
}

I find the following much better to read (C style)

function()
{
implementations;
}

kind regards,
Bart


 
Reply With Quote
 
 
 
 
Phlip
Guest
Posts: n/a
 
      10-10-2003
> Why is it that everybody likes the follwowing curly braces syntax
>
> function() {
> implementations;
> }


They don't. Some like it and some don't.

> I find the following much better to read (C style)
>
> function()
> {
> implementations;
> }


For style, I follow the ultimate acknowledge reference for English - /The
Elements of Style/.

It says to use parallel construction on parallel concepts.

Don't say, "The big red lion lay down with the lamb, small and furry".

Say, "The big red lion lay down with the small furry lamb."

The adjectives parallel their relation to their noun.

So, in programming, put the curly braces where they parallel each other.

--
Phlip


 
Reply With Quote
 
 
 
 
jeffc
Guest
Posts: n/a
 
      10-10-2003

"bart" <(E-Mail Removed)> wrote in message
news:3f86b7e8$0$58711$(E-Mail Removed)4all.nl...
> Why is it that everybody likes the follwowing curly braces syntax
>
> function() {
> implementations;
> }
>
> I find the following much better to read (C style)
>
> function()
> {
> implementations;
> }


I don't think everybody does like the former. I think at least half the
people prefer the latter.


 
Reply With Quote
 
Ron Natalie
Guest
Posts: n/a
 
      10-10-2003

"bart" <(E-Mail Removed)> wrote in message news:3f86b7e8$0$58711$(E-Mail Removed)4all.nl...
> Why is it that everybody likes the follwowing curly braces syntax
>
> function() {
> implementations;
> }
>
> I find the following much better to read (C style)
>
> function()
> {
> implementations;
> }
>

What makes you think the latter is C style? And what makes you think it's
easier to read?


 
Reply With Quote
 
Tim Clacy
Guest
Posts: n/a
 
      10-10-2003
bart wrote:
> Why is it that everybody likes the follwowing curly braces syntax
>
> function() {
> implementations;
> }
>
> I find the following much better to read (C style)
>
> function()
> {
> implementations;
> }
>
> kind regards,
> Bart


Some of us don't like either; they're there to make compiler writers lives
easier, not ours.


 
Reply With Quote
 
Stewart Gordon
Guest
Posts: n/a
 
      10-10-2003
While it was 10/10/03 2:50 pm throughout the UK, bart sprinkled little
black dots on a white screen, and they fell thus:
> Why is it that everybody likes the follwowing curly braces syntax
>
> function() {
> implementations;
> }


I'm one of everybody, amn't I? I personally hate it when people can't
be bothered to indent.

> I find the following much better to read (C style)
>
> function()
> {
> implementations;
> }


Well, I guess that

function() {
implementations;
}

gives the best of both worlds.

Stewart.

--
My e-mail is valid but not my primary mailbox. Please keep replies on
on the 'group where everyone may benefit.

 
Reply With Quote
 
Patrick Kowalzick
Guest
Posts: n/a
 
      10-10-2003
Hi bart,

> function() {
> implementations;
> }


This style has a very big advantage when you use a single-line debugger, In
fact not for a function. Try an if instead.

When you use these two cases with a single-line debugger...

if (someboolexpression)
dosomething;

if (someboolexpression) {
dosomethingmore;
}

...and the line with an if appears the curly brace tells you that a block is
following. If not one single command follows.

> function()
> {
> implementations;
> }


I personally like this style more. In my opinion it is more readable. But I
do not use a single-line debugger. So I assume that I am not part of
"everybody".

Regards,
Patrick


 
Reply With Quote
 
Thomas Matthews
Guest
Posts: n/a
 
      10-10-2003
bart wrote:

> Why is it that everybody likes the follwowing curly braces syntax
>
> function() {
> implementations;
> }
>
> I find the following much better to read (C style)
>
> function()
> {
> implementations;
> }
>
> kind regards,
> Bart
>
>


Some people like this style:
return_type
function()
{
implementation;
}
The braces show the indentation.

I prefer to have the braces line up to help show the indentation
levels.

But this is what they call a religious issue; there is no
correct answer, only what people believe.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

 
Reply With Quote
 
Tim Clacy
Guest
Posts: n/a
 
      10-10-2003
Tim Clacy wrote:
> bart wrote:
>> Why is it that everybody likes the follwowing curly braces syntax
>>
>> function() {
>> implementations;
>> }
>>
>> I find the following much better to read (C style)
>>
>> function()
>> {
>> implementations;
>> }
>>
>> kind regards,
>> Bart

>
> Some of us don't like either; they're there to make compiler writers
> lives easier, not ours.


....and just to set the cat amongst the pigeons, I'm quite fond of this:

void fn() {
while (...) {
switch (...) {
case :
case :
default : } } }




 
Reply With Quote
 
Default User
Guest
Posts: n/a
 
      10-10-2003
bart wrote:
>
> Why is it that everybody likes the follwowing curly braces syntax
>
> function() {
> implementations;
> }
>
> I find the following much better to read (C style)


If anything, the former is C-style, as it was used by the originators of
C in K&R. Often refered to as K&R style or OTBS (one true brace style).

>
> function()
> {
> implementations;
> }



I have a preference for Whitesmith's style:

if (1)
{
std::cout << "code!\n";
}


Just pick a style and use it consistently.



Brian Rodenborn
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Confused by route matching syntax anon6111@hotmail.com Cisco 2 07-17-2007 03:41 PM
Help with Pattern matching. Matching multiple lines from while reading from a file. Bobby Chamness Perl Misc 2 05-03-2007 06:02 PM
Regex-style pattern-matching for non-text? Calum MacLean Java 4 07-08-2004 08:18 AM
Need help with Style conversion from Style object to Style key/value collection. Ken Varn ASP .Net Building Controls 0 04-26-2004 07:06 PM
Pattern matching : not matching problem Marc Bissonnette Perl Misc 9 01-13-2004 05:52 PM



Advertisments