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?
Schol-R-LEA;2 ELF JAM LCF BiWM MGT GS
First Speaker, Last Eristic Church of Finagle and Holy Bisexuality #define KINSEY (rand() % 7)
// Keeper of the Tent Peg of Homosexuality +5You draw it, we misinterpret it.
- Bo Lindbergh // Realitas vestri renuo, sufficioque mei."Fundamentalism, not atheism, is the ultimate rejection of faith."