Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Feb 2001 07:22:47 +1100 (EST)
From:      Andy Newman <atrn@zeta.org.au>
To:        chat@FreeBSD.org
Subject:   Re: silly C style question 
Message-ID:  <200102012022.f11KMlq84246@juju.bsn>
In-Reply-To: <200101241124.f0OBOgm22341@dungeon.home>

next in thread | previous in thread | raw e-mail | index | archive | help
On 24 Jan, Stephen McKay wrote:
> Imported from Basser Department of Computer Science, University of Sydney?
> Piers Lauder was mad keen on this diabolical but extremely logical indenting
> scheme.

And Tim Long* wrote the paper on it, appeared in AUUGN in the mid-1980s
or there abouts and was re-published about five years ago. Very funny
piece (the tone of the article is hilarious).  I worked with Tim for a
significant amount of time (hello Iain :) and our development group
adopted the style below.  The thing it is attempting to do is aid
comprehension by allowing the "visual lexemes" to stand apart and
easily discerned.

Of course this is a very subjective thing, as the various "wars" of
coding style show, however over many years of trying nearly every
possible style of code layout (naming conventions and brace styles,
etc...)  I have found this style the best for overall readability.
It applies a visual structuring similar to what we do for control flow
to the terms/factors of expressions.  It's takes a little pragmatism
though - you don't willy nilly add vertical whitespace, it's added to
break up dense clumps of punctuation glyphs that hide the shapes of the
words we're trying to read.


(we got rid of any unnecessary parentheses and less whitespace when
indenting in our version of the style below).


> 
> Example:
> 
> 	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)
> 		)
> 	)
> 	...


* Tim did a lot of work on BSD and Unix in the early 1980s. Look on the
  list of people named on the USENIX award for the BSD work.


--
Andy



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?200102012022.f11KMlq84246>