From owner-freebsd-chat Thu Feb 1 12:23: 5 2001 Delivered-To: freebsd-chat@freebsd.org Received: from ska.bsn (CPE-144-132-209-248.nsw.bigpond.net.au [144.132.209.248]) by hub.freebsd.org (Postfix) with ESMTP id 67B6E37B684 for ; Thu, 1 Feb 2001 12:22:46 -0800 (PST) Received: from juju.bsn (juju.bsn [192.168.1.5]) by ska.bsn (8.9.3/8.9.3) with ESMTP id HAA57201 for ; Fri, 2 Feb 2001 07:23:08 +1100 (EST) (envelope-from andy@ska.bsn) Received: (from andy@localhost) by juju.bsn (8.11.1/8.9.3) id f11KMlq84246 for chat@FreeBSD.org; Fri, 2 Feb 2001 07:22:47 +1100 (EST) (envelope-from andy) Message-Id: <200102012022.f11KMlq84246@juju.bsn> Date: Fri, 2 Feb 2001 07:22:47 +1100 (EST) From: Andy Newman Reply-To: atrn@zeta.org.au Subject: Re: silly C style question To: chat@FreeBSD.org In-Reply-To: <200101241124.f0OBOgm22341@dungeon.home> MIME-Version: 1.0 Content-Type: TEXT/plain; CHARSET=US-ASCII Sender: owner-freebsd-chat@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org 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