Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 26 Jan 2001 07:47:40 -0500 (EST)
From:      Chris Fuhrman <cfuhrman@tfcci.com>
To:        Josef Grosch <jgrosch@mooseriver.com>
Cc:        Terry Lambert <tlambert@primenet.com>, Stephen McKay <mckay@thehub.com.au>, Iain Templeton <iain@research.canon.com.au>, <chat@FreeBSD.ORG>
Subject:   Re: silly C style question
Message-ID:  <Pine.LNX.4.30.0101260738000.21572-100000@icestorm.tfcc.com>
In-Reply-To: <20010125140416.A12493@mooseriver.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 25 Jan 2001, Josef Grosch wrote:

> The lack of a space between the if and the first parenthesis is unclean and
> violates style(9) and the space after each opening parenthesis and the lack of
> space before each closing parenthesis is also unclean and inconsistent. If one
> were being consistent it should be done like this :
>
>   	if ( ( id->id_type == NULL ) ||
>   	     ( ( id->id_type->x_what == xt_arrayof ) &&
>  	       ( item->x_left->x_what == xt_arrayof ) &&
>  	       ( id->id_type->x_subtype == item->x_left->x_subtype ) &&
>  	       ( id->id_type->x_flags & XIS_DIMLESS ) ) )
>

I'm more of a Perl programmer than a C programmer, but the one thing I
like to do, in any language, is to make code as clean and as readible as
possible, the main reason being so that I can look at the code and
remember the logic.  It also helps with anyone who has to maintain the
code at a later date.

  if ( ( id->id_type                  == NULL ) ||
       ( ( id->id_type->x_what        == xt_arrayof ) &&
         ( item->x_left->x_what       == xt_arrayof ) &&
         ( id->id_type->x_subtype     == item->x_left->x_subtype ) &&
         ( id->id_type->x_flags       &  XIS_DIMLESS ) ) ) {

  } /* if ( ( id->id_type                  == NULL ) || ... ) */

Out of curiousity, does anyone do function declarations like this?

  int myfunc (int    param1,
  	      int    param2,
	      char * jabber) {

  } /* myfunc */

I know it's something of a waste of space, but it helps with readability
immensely as far as figuring out what params a function takes.

Cheers!

-- 
Chris Fuhrman           | Twenty First Century Communications
cfuhrman@tfcci.com      | Software Engineer
(W) 614-442-1215 x271   |
(F) 614-442-5662        | PGP/GPG Public Key Available on Request



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-chat" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.LNX.4.30.0101260738000.21572-100000>