Subject: Re: proposed new KNF [was Re: Time to update KNF?]
To: None <tech-kern@netbsd.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-kern
Date: 01/17/2000 23:39:58
[Surely tech-kern isn't the right place for this - where is?]

> Here's [...] a [proposed] revised KNF style guide

Quite aside from whether I like this proposed KNF (I don't, on many
counts, on most of which I equally dislike the current KNF), I see some
internal inconsistencies.

> static char	*function(int, int, float, int);

> 	struct	foo	*next;		/* List of active foo */

> static char *
> function(int a1, int a2, float fl, int a4)

> 	int		*six, seven;
> 	char		*eight, *nine, ten, eleven, twelve, thirteen;
> 	char		 fourteen, fifteen, sixteen;

Why does the * attach to the variable name in variable declarations,
but behave like part of the type name in function declarations?  That
is, why isn't the function

static char
*function(int a1, int a2, float fl, int a4)

(I've never understood the reason for the former.  I can see, sort of,
how it makes it a little clearer when declaring multiple variables in a
single declarations, since each needs a *, or lack thereof, of its own
- but I've never understood why C was done that way; it makes trailing
*s an inconsistent part of a type name.  For that matter, I never
declare multiple variables in a single declaration, in part because of
this linguistic inconsistency.)

> /*
>  * Use ANSI function declarations.  ANSI function braces look like
>  * old-style (K&R) function braces.
>  */
> void
> function(int a1, int a2)

But you advised using __P for declarations for the sake of old
compilers.  If you're writing prototype definitions, there's no reason
to be generous to old compilers in the declarations, since the code
won't build on a pre-prototype compiler anyway.

Besides, I *think* an old-style declaration is not compatible with a
prototype definition, though gcc lets you get away with it anyway, as
an extension.

> static void
> usage()

If you do prototype definitions (as above), why no prototype here?

					der Mouse

			       mouse@rodents.montreal.qc.ca
		     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B