httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chuck Murcko <ch...@telebase.com>
Subject Re: Style guide
Date Wed, 03 Jul 1996 02:24:55 GMT
Here's my (humorous, yeet serious 8^) rehash:

Ben Laurie liltingly intones:
> 
> New in this version: 12c, 13, 14.
> 
> I decline to offer alternatives for comment style until someone can come up
> with some options which are both clear and enforcable.
> 
> As usual, please check that my records reflect your opinion, and again, again,
> please vote on 3a1 or 3ab.
> 
> Also, please let me know of any other issues requiring votes.
> 
> Cheers,
> 
> Ben.
> 
> 1. Function declarations
> Note: Illustrated using 7a.
> 
> a) int
>    main(...)
> b) int main(...)
> 

1b) I like to see the function decs as they fly by when paging.

> 2. Commas
> 
> a)	f(a, b);
> b)	f(a,b);
> 

2a) Much easier when the arg names get really long.

> 3. Braces
> 
> a1)	if(x) {
> 	    code;
> 	} else {
> 	    code;
> 	}
> a2)	if(x) {
> 	    code;
> 	}
> 	else {
> 	    code;
> 	}
> b)	if(x)
> 	{
> 	    code;
> 	}
> 	else
> 	{
> 	    code;
> 	}
> c)	if(x)
> 	    {
> 	    code;
> 	    }
> 	else
> 	    {
> 	    code;
> 	    }
> 

3b) You see,  I used 3a1 in my larval stage, when running on a Sinclair ZX-80
with a 40x16 display or a Teletype. I used 3a2 in my pupal stage, when I used
vt100's and the like. I use X now, and I use 3b to clearly delineate statement
blocks.

> 4. For statements
> 
> a)	for(a ; b ; c)
> b)	for(a; b; c)

4b) No need to go crazy on the horizontal (or vertical) space. I don't
skip a line after a conditional.

> 
> 5. Comment indentation
> 
> a)	code;
> 	/* comment */
> 	code;
> b)	code;
>     /* comment */
> 	code;
> 

5b) Only time I override this is for something*really* obtuse or important.
Comments for a particular line I allow to follow the program statement. These
can be multiline if necessary, but format vertically down from the original
start of the comment.

> 6. Switches
> Note: Illustrated using 3a.
> 
> a)	switch(x) {
> 	case a:
> 	    code;
> 	case b:
> 	    code;
> 	}
> b)	switch(x) {
> 	    case a:
> 		code;
> 	    case b:
> 		code;
> 	}

6b) Why indent at all if not?

> 
> 7. Function declarations(2)
> Note: Illustrated using 1b.
> 
> a) int main(...)
> b) int main (...)
> 

7a) The paren is there to set off the arguments. No space necessary.

> 8. Assignment
> 
> a)	a=b
> b)	a = b
> 

8b) Single letter examples don't begin to show why this is done. 8^)

> 9. Arithmetic operators
> 
> a)	a+b
> b)	a + b
> 

9b) See above.

> 10. Logical operators
> 
> a)	a<b
> b)	a < b
> 

10b) See above.

> 11. Incrementation
> 
> a)	++a
> b)	++ a
> 

11a) This must be a trick question.

> 12. Function declarations(3)
> Note: Illustrated using 1b, 7a.
> 
> a) int main()
>    {
> 	code;
>    }
> b) int main()
> 	{
> 	code;
> 	}
> c) int main() {
> 	code;
>    }

12a) See opinion 3.

> 
> 13. Null pointer tests
> 
> a) if(p == NULL)
> b) if(!p)
> 

Pass. I use whatever is appropriate, in context. For example:

	if(!done)
	if(!blownup)
	if(bumsucking_incredibly_obscure_variable == NULL)

> 14. Capitalisation of enums
> 
> a) enum x { ONE, TWO };
> b) enum x { one, two };
> c) No rule.
> 

14a) Enums are mass #defines that happen to be integer, usually.

	1  2  3  4  5  6  7  8  9 10 11 12 13 14 DF

Chuck	b  a  b  b  a  b  a  b  b  b  a  a  -  a  2
Randy   a  a  a2 a  a  a  b  b  b  b  a  a        3
Paul    a  a  a  b  a  b  a  b  b  b  a  a        2
Ben     b  b  c  a  b  a  a  a  a  b  a  b  b  c  7
RST     b  a  a2 b  a  a  b  b  b  b  a  a        1
Mark    b  b  a  b  a  b  a  b  b  b  a  a        2
David   a  a  b  a
Alexei  b  a  a2 b  a  a  b  b  b  b  a  a        1
Rasmus  b  a  a1 b  a  a  a  b  b  b  a  a        0.5
Jim     a  a  a2 b  a  a  a  b  b     a  a        1
Roy	b  a  b  b  a  b  a  b  b  b  a  a        2

Total   b  a  a2 b  a  a  a  b  b  b  a  a  b  c
> 

chuck
Chuck Murcko	N2K Inc.	Wayne PA	chuck@telebase.com
And now, on a lighter note:
"By the time they had diminished from 50 to 8, the other dwarves began
to suspect 'Hungry' ..."
		-- Gary Larson, "The Far Side"

Mime
View raw message