Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2002:
[Freeciv-Dev] Re: coding standard patch
Home

[Freeciv-Dev] Re: coding standard patch

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: coding standard patch
From: Jason Short <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 18 Sep 2002 16:11:09 -0500

Per I. Mathisen wrote:
Please read and criticize.

Index: doc/CodingStyle
===================================================================
RCS file: /home/freeciv/CVS/freeciv/doc/CodingStyle,v
retrieving revision 1.2
diff -u -r1.2 CodingStyle
--- doc/CodingStyle     2002/08/12 17:14:21     1.2
+++ doc/CodingStyle     2002/08/28 18:12:36
@@ -14,8 +14,11 @@
- An empty line should be placed between two separate blocks of code. -- Spaces should go before and after operators, and after commas:
+- Do not use tabs. Indentation should be by two spaces for each level
+  of code nesting.
+- Spaces should go before and after operators, expressions and commas:
+
 int a,b,c;   /* bad */
 int i, j, k; /* good */

Call me crazy, but I'm a big fan of tabs.

I can see how FreeCiv doesn't make good use of them, though. The ideal use for tabs is as a single level of indentation - that way if someone prefers a different level of indentation they can just change their tab width. But with an indentation level of 2 and a tab width of 8 this doesn't work - it just serves to make sure that people have to use a tab width of 8.


---side note---

To carry things a little farther, emacs and indent will automatically indent using tabs (or automatically strip tabs). But under the system of indentation I describe above, not *all* spaces should be replaced by tabs. Consider:

int foo(void)
{
\tint x;

\tcall_some_function(x, y
\t                   z);
}

Here I have written \t instead of a two-space tab. The above is the "proper" indentation: no matter how you change the tab/indentation width it will always look correct (although it may flow off the screen). But emacs and indent will give you this:

\tcall_some_function(x, y
\t\t\t\t\t\t\t\t\t\t z);

which will again only work with a tab width of 2.

Does anyone know how to get the first behavior instead of the second (in emacs or indent)?

jason



[Prev in Thread] Current Thread [Next in Thread]