2 Coding conventions
Comment much. I know, there are not too much comments in the code at the
very moment, but please forgive me, I'm working on it.
Leave code clean and warning free. This is especially true for gontc
warnings about pattern matching. The usual way of adding new things, is
to add them to unions, and fix switches, until you'll get warning-free
compilation :-)
Code should fit 80 column screen.
2.1 For C code
indent -kr -i8
, parse: K&R, tabstops are 8 spaces long.
Example (very stupid one):
int f(int a, int b)
{
while (a != 0) {
if (a == b) {
a = b;
} else {
b = c;
}
switch (c) {
case C1:
c = 1;
break;
case C2:
c = 2;
break;
}
}
}
Functions should be small (1-2 screens).
Why -kr? Because (1) K&R are right, (2) K&R are right,
and (3) K&R are right.
Why -i8? After 15th hour of hacking, you'll surly find out why...
If you get far too far to the right with such a huge indent,
it means your functions are far too big
(borrowed from CodingStyle file that comes with linux kernel).
2.2 For Gont code
Style: indent -kr -i4
. Why not 8? Because Gont offers nested
functions, which allow better code organization. Functions should still
be small, but not counting nested functions.
It is often to good to list all cases in patter matching, since we'll get
warning about it after adding new element to union.