Guidelines about coding style |
There a few rules about coding style that we try to follow ourselves
in the
In general, we try to avoid abbreviations when chosing names for global variables, functions, classes and categories, and choose short (often one letter) names for local variables. For instance:
|
Of course, standard mathematical functions such as
Use lowercase names for variables and functions.
For names of types and categories, capitalize the first letter of
each word categories (e.g.
Capitalize all letters in macro names.
Use the
The following indentation rules are implemented both in TeXmacs and in
the
Blocks of code are usually indented by two spaces. For instance:
|
Multiple line bodies of keywords are enclosed between braces
|
Input/output operators are indented as follows:
|
Functions or vectors with many arguments are indented as follows:
|
Sometimes, the readability can be enhanced by using ad hoc indentation rules:
|
There are a few less strict rules concerning whitespace management:
Function application takes one space before the bracket
|
and similarly for data access using
|
When the name of the function or data structure is particularly
short, we may omit the space before
|
Long mathematical expressions which do not fit on one line, such as
|
are usually split over several lines, by introducing some auxiliary variables
|
When defining a succession of variables, align the definitions on
the
|
Use whitespace around mathematical infix operations whenever this enhances readability:
|