Coding conventions¶
Formatting¶
There are no explicit formatting conventions since we use clang-format
(C++) and yapf
(Python).
Integer types¶
Do not use unsigned integers, including
size_t
. Instead, usescipp::index
which is a typedef forint64_t
. See ES.107 for details. The free functionscipp::size
is provided as a free helper function to obtain a signed index for standard containers such asstd::vector
where thesize
method returns a forbiddensize_t
.Do not use variable-width integers such as
int
orlong
. These may be 32 bit or 64 bit depending on platform and compiler. Instead, useint32_t
andint64_t
. Variable widthint
is acceptable in loops with known small extent, e.g., infor (int i=0; i<4; ++i)
.
Testing¶
As a general rule all new functionality and bug fixes should be accompanied with sufficient unit tests to demonstrate that the feature or fix works as intended.