473,700 Members | 2,616 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

matching { } syntax style

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
Jul 19 '05 #1
31 2491
> 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
Jul 19 '05 #2

"bart" <ba**@thatissec ret.nlm> wrote in message
news:3f******** *************** @news.xs4all.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.
Jul 19 '05 #3

"bart" <ba**@thatissec ret.nlm> wrote in message news:3f******** *************** @news.xs4all.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?
Jul 19 '05 #4
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.
Jul 19 '05 #5
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.

Jul 19 '05 #6
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.l earn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

Jul 19 '05 #7
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 (someboolexpres sion)
dosomething;

if (someboolexpres sion) {
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
Jul 19 '05 #8
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 : } } }

:-)
Jul 19 '05 #9
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
Jul 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

24
2705
by: Andrew Koenig | last post by:
PEP 315 suggests that a statement such as do: x = foo() while x != 0: bar(x) be equivalent to while True:
2
2583
by: Peter Fein | last post by:
I'm trying to use pyparsing write a screenscraper. I've got some arbitrary HTML text I define as opener & closer. In between is the HTML data I want to extract. However, the data may contain the same characters as used in the closer (but not the exact same text, obviously). I'd like to get the *minimal* amount of data between these. Here's an example (whitespace may differ): from pyparsing import *
9
3211
by: Xah Lee | last post by:
# -*- coding: utf-8 -*- # Python # Matching string patterns # # Sometimes you want to know if a string is of # particular pattern. Let's say in your website # you have converted all images files from gif # format to png format. Now you need to change the # html code to use the .png files. So, essentially
1
3485
by: Stephen | last post by:
I am unable to get intelligent font matching to work. I used a @font-face with a Panose-1 descriptor. I tried it with both Internet Explorer 6 and Firefox on Windows 98 SE. The Panose numbers are from the Windows Registry key HKEY_LOCAL_MACHINE\Software\Microsoft\Shared Tools\Panose. I am unsure if I made a coding error, or if the browsers do not support intelligent font matching, or if there is some other cause. In the example shown...
18
1769
by: Chris Mantoulidis | last post by:
There is a LARGE number of syntax styles in most (if not all) programming languages. For example, one syntax style (my current one): .... int main() { for (int i = 0; i < 50; i++) {
4
7616
by: Bob hotmail.com> | last post by:
Everyone I have been spending weeks looking on the web for a good tutorial on how to use regular expressions and other methods to satisfy my craving for learning how to do FAST c-style syntax highlighting in C# but I have yet to find anything useful I know there are people at MS that know this stuff like the front of their hand and I know there are many people out on the web that are proficient in doing this as well but it seems nobody...
8
2237
by: Xah Lee | last post by:
the Python regex documentation is available at: http://xahlee.org/perl-python/python_re-write/lib/module-re.html Note that, i've just made the terms of use clear. Also, can anyone answer what is the precise terms of license of the official python documentation? The official python.org doc site is not clear. Note also, that the regex syntax used by Perl is the same as Python.
3
2353
by: Magnus.Moraberg | last post by:
multipleSpaces = re.compile(u'\\h+') importantTextString = '\n \n \n \t\t ' importantTextString = multipleSpaces.sub("M", importantTextString) I would have expected consecutive spaces and tabs to be replaced by M but nothing is being replaced. If I try the following, then I'm left only with M, as expected - multipleSpaces = re.compile(u'\\s+') # both vertical and horizontal
21
2450
by: REH | last post by:
It it permissible to use the constructor style cast with primitives such as "unsigned long"? One of my compilers accepts this syntax, the other does not. The failing one chokes on the fact that the type is not a single identifier or keyword. Which one is correct? For example: unsigned long x = unsigned long(y); REH
0
9203
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9060
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7797
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6557
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5897
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4396
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4650
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2021
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.