The Nightstar Zoo
http://zoo.nightstar.net/

Proposal for a brace style notation
http://zoo.nightstar.net/viewtopic.php?f=90&t=13991
Page 1 of 1

Author:  Schol-R-LEA [ Sat Nov 12, 2005 1:40 pm ]
Post subject:  Proposal for a brace style notation

It has occurred to me that it would help if programmers for languages using braces had a notation for describing the different brace styles succinctly. My specific proposal is for a series of letter-number codes for each each of the possible brace locations and indent levels. The first code would be the location of the leading brace and it's indentation (with the letter code in upper case), the second the code indentation, the third the position and indentation of the trailing brace (with the letter in lowercase), the fourth the handling of braces around else statements (and the spacing around the code body in the case of cuddled elses), and the fifth for the handling of single expressions (and the spacing around the code body for in-line blocks).

The letter abbreviations would be T (terminal, for the lead brace at the end of the expression), S (successive, for the lead brace on the line following the expression), C (cuddled, for 'cuddled' elses, e.g., ones with the closing brace of the if and the opening brace of the else on the same line as the else itself), U (uncuddled) and the spacing around the code body, L (linear, for a single-statement body that has both braces inline with the statement), N (non-linear, for applying the normal brace rules to single statement blocks), and B (bare, for single expressions with no braces).

For example, 1TBS as it's usually described would be T1:8:s0:C0:B. Similarly, GNU style would be S3:8:s3:U:N, and Allman style would be S0:8:s0:U:B. Since the most common cases do not use cuddled braces, have the trailing brace on the line following the code body with no indentation, and (unfortunately) omit braces around single expressions, the latter could be abbreviated to S0:8.

While this is cryptically terse, it does cover most of the common variations on brace style as I know them. Any comments or alternatives?

Author:  jerith [ Wed Nov 16, 2005 7:11 am ]
Post subject: 

Is this so we can make brace style wars easier or more difficult to read?

*grin*

Page 1 of 1 All times are UTC - 6 hours [ DST ]
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/