diff --git a/CODING-STYLE.md b/CODING-STYLE.md new file mode 100644 index 0000000..9bb334d --- /dev/null +++ b/CODING-STYLE.md @@ -0,0 +1,37 @@ +Tabs vs. Spaces +--------------- + +Tabs are only used at the beginning of a line, and only used to express indentation level. Spaces are used +for any other type of vertical alignment, e.g. aligning function arguments. This ensures that the code +displays correctly everywhere, regardless of the viewer's tab size, and does not inflict the viewer with my +choice of tab size (8 spaces). + +I use the emacs smart-tabs-mode to automatically enforce this. +See https://www.emacswiki.org/emacs/SmartTabs for more information. + + +Indentation Style +----------------- + +Glabels code uses the Allman (a.k.a "BSD Style") of code indentation. I.e. the brace associated with a +control statement is placed on the next line, indented to the same level as the control statement. +Statements within the braces are indented to the next level. + +``` +while ( condition ) +{ + something(); + somethingElse(); +} + +if ( condition2 ) +{ + handleCondition2(); +} +else +{ + somethingElse(); +} +``` + +See https://en.wikipedia.org/wiki/Indent_style#Allman_style for more information.