Coding style
Closed this issue · 11 comments
This is something we need to decide. Now there are functions written in camelCase and in snake_case. Some of these are my doings, some by others.
Generally I do things in camelCase, but I think we should have both depending on the case.
For example, we could have snake_case for an entity's properties (e.g. entity_speed) and camelCase for functions (e.g. entityMove())
I agree with @LIESard.
We also need to choose the indentation: some parts are written with 4-spaces indentation and some with 8-spaces. I personnally prefer and use 4 spaces
I personally use tabs, that way people can configure how wide things are for themselves, and it's less button presses. I personally use 4-character wide tabs.
I think it should be 4-character wide tabs which are then converted to spaces
Most people use 4 characters and it's not too small and not too wide
And if we convert them to spaces then it won't mess up on other people's text editors
Is there any way to get astyle to (intelligently) stick to line width? I imagine we all agree we can't have lines going over a certain number (80?) characters.
Do you prefer:
- Allman style:
while (x == y)
{
something();
somethingelse();
}
finalthing();
- GNU style:
static char *
concat (char *s1, char *s2)
{
while (x == y)
{
something ();
somethingelse ();
}
finalthing ();
}
- BSD style:
if (data != NULL && res > 0) {
if (JS_DefineProperty(cx, o, "data",
STRING_TO_JSVAL(JS_NewStringCopyN(cx, data, res)),
NULL, NULL, JSPROP_ENUMERATE) != 0) {
QUEUE_EXCEPTION("Internal error!");
goto err;
}
PQfreemem(data);
} else {
if (JS_DefineProperty(cx, o, "data", OBJECT_TO_JSVAL(NULL),
NULL, NULL, JSPROP_ENUMERATE) != 0) {
QUEUE_EXCEPTION("Internal error!");
goto err;
}
}
- Lisp style:
for (i = 0; i < 10; i++) {
if (i % 2 == 0) {
doSomething(i); }
else {
doSomethingElse(i); } }
Or do you use something else ?
I personnally prefer the Allman style.
BSD
BSD
Allman, but I though we'd decided BSD?