[Freeciv-Dev] Re: Coding Guideline RFC
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Sun, Nov 25, 2001 at 05:03:54PM +0000, Gregory Berkolaiko wrote:
> /***************
> * 1: init vars
> ***************/
>
> /* A */
> int foo1a(struct city *punit)
> {
> int x = punit->x;
> }
Because it is shorter.
> /**************************
> * 2: empty line after vars
> **************************/
>
> /* B */
> int foo2b(void)
> {
> int x;
>
> x = 3;
> }
More clear.
> /****************
> * 3: comments
> ****************/
>
> /* B */
> int foo3b(int x)
> {
> /* assign 3 to x */
> x = 3;
> }
Because it can be more easily expand if the room isn't enough. See
also <http://www.uwsg.iu.edu/hypermail/linux/kernel/0101.2/0799.html>
> /**************************
> * 4: extra {} on iterates
> **************************/
> /* A */
> unit_list_iterate(pcity->units_supported, punit) {
> kill(punit);
> } unit_list_iterate_end;
>
> /******************************************
> * 5: unnecessary braces after conditionals
> ******************************************/
> int foo5(int x)
> {
>
> /* A */
> if (x == 3) {
> return;
> }
> }
>
> /****************************************************
> * 6: unnecessary braces after conditionals with else
> ****************************************************/
> int foo6(int x)
> {
>
> /* A */
> if (x == 3) {
> return 1;
> } else {
> return 0;
> }
> }
4, 5 and 6 are the same. Reason: can be more easily changed.
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
"It is not yet possible to change operating system by writing
to /proc/sys/kernel/ostype." sysctl(2) man page
- [Freeciv-Dev] Re: PATCH: AI cleanup Version 2, (continued)
- [Freeciv-Dev] Re: PATCH: AI cleanup Version 2, Raimar Falke, 2001/11/24
- [Freeciv-Dev] Re: PATCH: AI cleanup Version 2, Petr Baudis, 2001/11/24
- [Freeciv-Dev] Re: PATCH: AI cleanup Version 2, Raimar Falke, 2001/11/24
- [Freeciv-Dev] Re: PATCH: AI cleanup Version 2, Petr Baudis, 2001/11/24
- [Freeciv-Dev] Re: PATCH: AI cleanup Version 2, Raimar Falke, 2001/11/25
- [Freeciv-Dev] Re: PATCH: AI cleanup Version 2, Petr Baudis, 2001/11/25
- [Freeciv-Dev] Coding Guideline, Gregor Zeitlinger, 2001/11/25
- [Freeciv-Dev] Coding Guideline RFC, Gregory Berkolaiko, 2001/11/25
- [Freeciv-Dev] Re: Coding Guideline RFC, Greg Wooledge, 2001/11/25
- [Freeciv-Dev] Re: Coding Guideline RFC, Daniel Sjölie, 2001/11/25
- [Freeciv-Dev] Re: Coding Guideline RFC,
Raimar Falke <=
- [Freeciv-Dev] Re: Coding Guideline RFC, Raimar Falke, 2001/11/26
- [Freeciv-Dev] Re: Coding Guideline RFC, Petr Baudis, 2001/11/26
- [Freeciv-Dev] Coding Guideline Updated RFC, Gregory Berkolaiko, 2001/11/26
- [Freeciv-Dev] Re: Coding Guideline Updated RFC, Gregory Berkolaiko, 2001/11/26
- [Freeciv-Dev] Re: Coding Guideline Updated RFC, Andrew Sutton, 2001/11/26
- [Freeciv-Dev] Re: Coding Guideline Updated RFC, Raimar Falke, 2001/11/26
- [Freeciv-Dev] Re: Coding Guideline Updated RFC, Andrew Sutton, 2001/11/26
- [Freeciv-Dev] Re: Coding Guideline Updated RFC, Mike Kaufman, 2001/11/27
- [Freeciv-Dev] Please vote!, Gregory Berkolaiko, 2001/11/28
- [Freeciv-Dev] Re: Please vote!, Petrus Viljoen, 2001/11/28
|
|