CodingStyle revision 1.1 1 1.1 mrg This document describes some aspects of the coding style of isl,
2 1.1 mrg which is similar to that of the linux kernel and git.
3 1.1 mrg
4 1.1 mrg The general rule is to use the same style as that of the surrounding code.
5 1.1 mrg
6 1.1 mrg More specific rules:
7 1.1 mrg - every line should have at most 80 columns
8 1.1 mrg - use tabs for indentation, where a tab counts for 8 characters
9 1.1 mrg - use single spaces around binary operators such as '+', '-', '=', '!='
10 1.1 mrg - no space after unary operators such as '!'
11 1.1 mrg - use a single space after a comma and a semicolon
12 1.1 mrg (except at the end of a line)
13 1.1 mrg - no space between function name and arguments
14 1.1 mrg - use a single space after control keywords such as if, for and while
15 1.1 mrg - use a single space between the type of a cast and the value
16 1.1 mrg that is being cast
17 1.1 mrg - no whitespace at the end of a line
18 1.1 mrg - opening brace of a function is placed on a new line
19 1.1 mrg - opening brace of other blocks stays on the same line
20 1.1 mrg - the body of a control statement is placed on the next line(s)
21 1.1 mrg - an else appears on the same line as the closing brace of
22 1.1 mrg the then branch, if there is such a closing brace
23 1.1 mrg - if either the then or the else branch of an if has braces,
24 1.1 mrg then they both have braces
25 1.1 mrg - no parentheses around argument of return keyword
26 1.1 mrg - use only C style comments (/* ... */)
27 1.1 mrg - no comments inside function bodies;
28 1.1 mrg if some part of a function deserves additional comments, then
29 1.1 mrg extract it out into a separate function first
30 1.1 mrg - no #ifs inside function bodies
31 1.1 mrg - variables are declared at the start of a block, before any
32 1.1 mrg other statements
33 1.1 mrg
34 1.1 mrg There are some exceptions to the general rule of using
35 1.1 mrg the same style as the surrounding code, most notably
36 1.1 mrg when the surrounding code is very old.
37 1.1 mrg In particular, an "isl_space" used to be called "isl_dim" and
38 1.1 mrg some variables of this type are still called "dim" or some variant thereof.
39 1.1 mrg New variables of this type should be called "space" or a more specific name.
40 1.1 mrg Some old functions do not have memory management annotations yet.
41 1.1 mrg All new functions should have memory management annotations,
42 1.1 mrg whenever appropriate
43