Factbites
 Where results make sense
About us   |   Why use us?   |   Reviews   |   PR   |   Contact us  

Topic: One True Brace Style


Related Topics
XNA

  
  A Word on Style
However tempting it may be to ignore style completely-or at least give it a tertiary role-it is vital that it be taught and enforced at the early stages of C++ education.
Brace style is undoubtedly one of the most inflammatory issues surrounding C++ formatting.
Kernighan and Ritchie (One True Brace Style or 1TBS)
www.apl.jhu.edu /~doug/CppStyleGuide-Whitesmith.htm   (1026 words)

  
 One True Brace Style
One True Brace Style is a style in writing computer programs in the C programming language, and its derivatives, like C++.
Also known as K&R style, named after Kernighan and Ritchie, because the examples in their seminal book are formatted this way.
Also called "kernel style" because the Unix kernel[?] is written in it.
www.ebroadcast.com.au /lookup/encyclopedia/1t/1TBS.html   (107 words)

  
 Ailanto : The One True Brace Style
Thus the braces are part of the compound statement, not part of the guard or controlling statement— the braces are paired, one opening and one closing, and so should be at the same level of indentation— and the indentation of the braces should match that of the statements in the block, giving...
It is the One True Brace Style, logical and clear, and I found out later that it has a name: it is known as Whitesmiths Style, because it was the style used in examples that came with Whitesmiths C, an early commercial C compiler.
BSD Style, or Allman Style, pushes the braces further left, to the indentation level of the guard or controlling statement, and this is a Bad Thing, because it appears that the braces are part of the guard or controlling statement; they are not.
www.komputado.com /eseoj/1tbs.htm   (432 words)

  
 Programming Style
Programming style or "coding conventions" as it is sometimes called is about how you code so that the code is easily readable and understandabale by a human.
Style two, called Allman or BSD style, avoids this problem (see below), since the blank line introduced by the opening brace sets conditional and dependent code apart.
Style four is a strange mix bettween this and BSD-style, and is used as the official style of the GNU project.
www.schacherer.de /frank/tech/coding/style.html   (2981 words)

  
 indent style - FOLDOC Definition
There are four major C indent styles, described below; all have the aim of making it easier for the reader to visually track the scope of control constructs.
Also called "kernel style" because the Unix kernel is written in it, and the "One True Brace Style" (abbreviation 1TBS) by its partisans.
The opening brace tends to get lost against the right parenthesis of the guard part in an "if" or "while", which is a Bad Thing.
www.nightflight.com /foldoc-bin/foldoc.cgi?indent+style   (386 words)

  
 COEN 176: Coding Style
The first and foremost rule of coding style is to follow the style of the module you are modifying, however egregious it may be.
The One True Brace Style is that used by Kernighan and Ritchie in their classic text on C, and is the style used in BSD, Linux, and Minix.
If the closing brace does not end the statement, it should be at the beginning of the next line of the statement, at the same indentation as the line that opened the block it closes.
www.cse.scu.edu /~jnoll/176/projects/style-guide.html   (1089 words)

  
 3.7.2. Braces
It is common in the Java developer community to have the opening brace at the end of the line of the keyword for all types of blocks (Sun brace style).
Per definition braces are superfluous on single statements, but it is a common recommendation that braces should be always used in such cases.
Causes the left curly brace of the empty brace block to be positioned according to the current brace style settings.
www.triemax.com /products/jalopy/manual/braces.html   (1627 words)

  
 Blocks   (Site not responding. Last check: 2007-09-10)
One True Brace (OTB, KandR style): In v1.0.41+, the OTB style may optionally be used in the following places: expression if-statements, the "else" keyword, normal loops, and function definitions.
This style puts the block's opening brace on the same line as the block's controlling statement rather than underneath on a line by itself.
However, open-braces of the One True Brace style do not support commands to their right.
www.autohotkey.com /docs/commands/Block.htm   (272 words)

  
 Indian Hill C Style Manual   (Site not responding. Last check: 2007-09-10)
When changing existing code it is better to conform to the style (indentation, spacing, commenting, naming conventions) of the existing code than it is to blindly follow this document.
The opening brace ({) should be on the same line as the structure tag, and the closing brace (}) should be in column one.
The style for ANSI C is the same as for regular C, with two notable exceptions: storage qualifiers and parameter lists.
www.comsc.ucok.edu /~stockwel/cstyle.html   (10778 words)

  
 kasia in a nutshell: Coding and brace styles..
The style that puts the braces at the same indent level as the enclosed statements comes from people who'd prefer to be writing in Pascal or Algol 60.
I have to agree that the original C style indenting is hideous, because it is not clear where blocks of code begin and end and therefore it is hard to read.
Since bracing and indentation style arguments are really religious wars, I have a feeling that One True Brace is kind of like "True Christian" -- the proponent of a particular style lays claim to the title.
www.unix-girl.com /blog/archives/000027.html   (1179 words)

  
 The Daily WTF - Reply to an Existing Message - Re: indentation   (Site not responding. Last check: 2007-09-10)
has been going on ever since braces were used for the first time in a programming language.
In BSD style they are aligned, but then the text in the block is sitting out there in whitespace all alone.
In Whitesmith style at least the curlies line up and tie the block visually to the conditional.
thedailywtf.com /forums/AddPost.aspx?PostID=47540&Quote=True   (401 words)

  
 Visual Studio Feature proposal
If the code was written with the brace on the next line, but was viewed in the brace-on-end-of-line format then two lines would be merged.
Brace placement is not a big deal, although it is a subject of constant "holy wars" among developers.
The most important part is being consistent, at least for every project, so you may say that C and C++ code uses KandR style and C# code uses the aligned brace style or something like that.
channel9.msdn.com /ShowPost.aspx?PostID=225478   (721 words)

  
 [No title]
All true believers doth wish for a better error-handling mechanism, for explicit checks of return codes are tiresome in the extreme and the temptation to omit them is great.
While it is true that some features of the C libraries were ill-advised, by and large it is better and cheaper to use the works of others than to persist in re-inventing the square wheel.
While thou might think that thine own ideas of brace style lead to clearer programs, thy successors will not thank thee for it, but rather shall revile thy works and curse thy name, and word of this might get to thy next employer.
www.plethora.net /~seebs/c/10com.txt   (1618 words)

  
 CSC 3453 Project Notes: Coding Style   (Site not responding. Last check: 2007-09-10)
These are based on the ``Linux kernel coding style'' document, author unknown (although I believe it is Linus Torvalds himself), that is part of the Linux kernel source distribution.
It might be OK to use your own style on your own programs, but following a widely accepted style makes your code more readable by others, which is essential when working in a group or on a long lived project.
The One True Brace Style is that used by Kernighan and Ritchie in their classic text on C, and is the style we will follow.
carbon.cudenver.edu /~jnoll/3453/style-guide.html   (1288 words)

  
 Day 2 -- Basic Operators and Control Flow
operator returns either true or false, it is ideal for use in conditional expressions, because conditional expressions are expected to evaluate to either true or false.
I prefer the one true brace style because it is both legible and compact.
A conditional statement consists of two components: a conditional expression, which yields a result of either true or false; and a statement block, which is a group of statements that is executed only when the conditional expression is true.
wwwacs.gantep.edu.tr /docs/perl-ebook/ch2.htm   (5009 words)

  
 Recommended C Style and Coding Standards
This document is a modified version of a document from a committee formed at AT&T's Indian Hill labs to establish a common set of coding standards and recommendations for the Indian Hill community.
We (see footnote 1) have tried to combine previous work [1,6,8] on C style into a uniform set of standards that should be appropriate for any project using C, although parts are biased towards particular systems.
The opening brace of the function body should be alone on a line beginning in column 1.
www.chris-lott.org /resources/cstyle/indhill-cstyle.html   (9674 words)

  
 Douglas W. Jones Manual of C Style
Furthermore, a style well suited to feasibility studies, small algorithms and introductory courses may be quite inappropriate for large-scale system development.
Some elements of style are easily stated in objective terms, for example, the directive to use tabs for indenting; other style elements are extremely difficult to state objectively, for example, the subjective requirement for meaningful identifers.
Instead, we require that the opening brace for a block occur at the end of the line that introduces that block, and that the closing brace occur at the start of the line that marks the end of that block.
www.cs.uiowa.edu /~jones/syssoft/style.html   (5350 words)

  
 Dan Fernandez's Blog : It's all a matter of style
I find it interesting that style guides say that Allman and Whitesmith's are equal in prevalence as I have come across no-one else who uses the same style as me and have suffered much chastising about it -- I do see Allman's a great deal, though.
I break my own style by allowing opening and closing braces to be on one line in those cases but I'd much rather have the braces than not.
I think statements like "Braces should not get their own line, only statements" are stupid - for one, braces ARE statements, in a way (think Pascal begin and end).
blogs.msdn.com /danielfe/archive/2003/11/24/51893.aspx   (2550 words)

  
 Coding Standards
This includes braces for a class, a method, and braces that contain a code block for if/else statements.
The Hacker's Dictionary refers to this as the "`Allman style' -- Named for Eric Allman, a Berkeley hacker who wrote a lot of the BSD utilities in it (it is sometimes called `BSD style').
The things that must be true when calling the method and the things that will be true when the method is done assuming the preconditions were met.
www.cs.utexas.edu /~scottm/cs307/handouts/codingStandards.htm   (1724 words)

  
 Code Guidelines - OpenLaszlo
It keeps the first opening brace on the same line as control statement, indents the statements within the braces, and puts the closing brace on the same indentation level as the control statement (on a line of its own), as shown here.
The above code defines an indent style for all C-like languages, javascript being one, and what is used in LZX script.
There are several indentation styles in the existing code.
wiki.openlaszlo.org /Code_Guidelines   (601 words)

  
 The ten commandments for c programmers [Archive] - CampCAEN Forums
8- The one true brace style is ugly.
As for the one true brace style, I hate when people put the brace on a new line.
But justin is right, if you must be a heathen and go astray from the one true style, do it consistantly.
forums.caenage.com /archive/index.php/t-275.html   (826 words)

  
 Polystyle - Multi-Language Source Code Formatter - Step 2: Example C/C++ Source
Each example file come in various indent styles, such as 2-space, 1-tab, 4-space, and others.
Your style is easily configured using the Configuration Tool.
This means * changing the whitespace padding between tokens, placement of newlines, and * the indents to match your style.
www.polystyle.com /features/c-example.jsp   (595 words)

  
 PHPBuilder.com - Coding Style
KandR Style Named after Kernighan and Ritchie, because the examples in KandR are formatted this way.
Whitesmiths Style popularized by the examples that came with Whitesmiths C, an early commercial C compiler.
I'll use Java Style for quick easy scripts, but I usually watch my formatting (C Style is the best formatted) for anything complex.
www.phpbuilder.com /board/printthread.php?t=10234388   (692 words)

  
 Live from Tokyo: Tech Blog: C# Style Checking Tool
With a fixed style, all the code in the company is written to a higher standard as people take more pride in their work.
Arguments about the one true brace layout style or tab indentation size go away because the chosen style, whatever it is, is the law.
If you search Google for java code style checker the first site that comes up is the Checkstyle Home Page.
www.stuartwoodward.com /tech/archives/000399.html   (324 words)

  
 Jargon 4.2, node: indent style
`KandR style' -- Named after Kernighan and Ritchie, because the examples in KandR are formatted this way.
`Allman style' -- Named for Eric Allman, a Berkeley hacker who wrote a lot of the BSD utilities in it (it is sometimes called `BSD style').
KandR/1TBS used to be nearly universal, but is now much less common in C (the opening brace tends to get lost against the right paren of the guard part in an `if' or `while', which is a Bad Thing).
www.science.uva.nl /~mes/jargon/i/indentstyle.html   (472 words)

  
 [PEPr] +1 for System::System_Serial
If there is nothing in CS specifi cally about this, the / should be level with the code it's commenting, the * should be one more space in as should the */.
Like this: /** * */ function foo() { } NULL should be null (I believe) Function definitions should use the one true brace style: function ($arg) { //code } -- Sent by PEPr, the automatic proposal system at http://pear.php.net
If there is nothing in CS speci fically about this, the / should be level with the code it's commenting, the * should be one more space in as should the */.
www.codecomments.com /message291363.html   (357 words)

  
 Essay #4: Introduction to C - nuwen.net
Anywhere a statement appears, a compound statement may appear, which is simply a bunch of statements enclosed in braces.
The braces which make up a function body aren't optional, though, whereas if you have a compound statement with only one statement inside, you can eliminate the braces.
Always format them as I have done: Put the opening brace on the first line, with a space between it and whatever preceeds it, then indent any code that comes below it four spaces, and then finish with a closing brace on a line of its own, at the original indentation level.
nuwen.net /essay4.html   (2512 words)

Try your search on: Qwika (all wikis)

Factbites
  About us   |   Why use us?   |   Reviews   |   Press   |   Contact us  
Copyright © 2005-2007 www.factbites.com Usage implies agreement with terms.