[comp.lang.c] Style wars

blarson@skat.usc.edu (Bob Larson) (12/18/88)

Since this flamefest has come up again, I thought I would contribute
something I consider more readable than the "standard" representation.
Null statements are sometimes useful in C, mainly as loop bodies.

Some people use semicolon on a line by itself for the null statment.
I prefer a pair of braces:

		for(p = FIRST; p->next != NULL; p = p->next)
		    ;

looks strange to me, and takes two vertical lines.

		for(p = FIRST; p->next != NULL; p = p->next) {}

uses a special two character sequence to denote the null statement,
and takes only a single line.

(Vertical space is limited on the terminals I use to read and edit
programs, when comparing programs or looking at an insert file, only
11 lines of the function are visable.)
-- 
Bob Larson	Arpa: Blarson@Ecla.Usc.Edu	blarson@skat.usc.edu
Uucp: {sdcrdcf,cit-vax}!oberon!skat!blarson
Prime mailing list:	info-prime-request%ais1@ecla.usc.edu
			oberon!ais1!info-prime-request

gregg@ihlpb.ATT.COM (Wonderly) (12/20/88)

From article <14128@oberon.USC.EDU>, by blarson@skat.usc.edu (Bob Larson):
] Since this flamefest has come up again, I thought I would contribute
] something I consider more readable than the "standard" representation.
] Null statements are sometimes useful in C, mainly as loop bodies.
] 
] Some people use semicolon on a line by itself for the null statment.
] I prefer a pair of braces:
] 
] 		for(p = FIRST; p->next != NULL; p = p->next)
] 		    ;
] 
] looks strange to me, and takes two vertical lines.
] 
] 		for(p = FIRST; p->next != NULL; p = p->next) {}

I prefer

 		for(p = FIRST; p->next != NULL; p = p->next)
 		    continue;

which is completely obvious and not so strange...

-- 
It isn't the DREAM that NASA's missing...  DOMAIN: gregg@ihlpb.att.com
It's a direction!                          UUCP:   att!ihlpb!gregg

maart@cs.vu.nl (Maarten Litmaath) (12/21/88)

blarson@skat.usc.edu (Bob Larson) writes:
\(Vertical space is limited on the terminals I use to read and edit
\programs, when comparing programs or looking at an insert file, only
\11 lines of the function are visable.)

What kind of terminals are you using? Stony-Age 1(TM)?
-- 
fcntl(fd, F_SETFL, FNDELAY):          |Maarten Litmaath @ VU Amsterdam:
      let's go weepin' in the corner! |maart@cs.vu.nl, mcvax!botter!maart

md@sco.COM (Michael Davidson) (12/23/88)

In article <14128@oberon.USC.EDU> blarson@skat.usc.edu (Bob Larson) writes:
>		for(p = FIRST; p->next != NULL; p = p->next) {}
>uses a special two character sequence to denote the null statement,
>and takes only a single line.

I much prefer to use continue as the null statement in the context
of a loop body, ie:
		for (p = FIRST; p->next != NULL; p = p->next)
			continue;

bks@ALFA.berkeley.edu (Brad Sherman) (12/29/88)

	There are other stylistic questions apart from curly brace placement
and degree of indentation.  (By the way, source code control systems may
thrash if cb and indent are used injudiciously %}.)
	If there are 100 functions in the program are there 100 source files?
If not, what "rules" should be followed to chunk functions? (I used to
put the I/O routines in files with the functions which needed them; then
we started porting to odd ?NIX machines, VMS, and DOS-networks, now it seems
"better" to hide all those #ifdef's in I/O dependent files?!).
	Does every source file have a declaration of *every* global
(perhaps via #include "global.h"), or should it be done on a need-to-know
basis at the top of the file?  Or only in the body of the function which
references it?
	Under what circumstances should sets of variables be glued together
into structures? Should functions know about variables which they don't
look at or modify?
	If 10% of the functions need to know about a variable, should it 
be made global? 50%? 90%?
	How are we to document soon to be heavily used code (i.e. sure to be
modified after some experimentation)? If I find a nicely troff'ed document
from 10/86 describing your program, but I see that 10 sccs entries (i.e.
modification dates) have occurred since, should I read the document or
studiously avoid it?

	" ... We might suggest that programmers adopt a systematic 
	stategy when they need to understand a program.  While
	reasonable, this is a totally impractical suggestion: a
	systematic stategy can only really be adopted when a program
	is smallish ...  If a programmer attempted to use the
	systematic stategy on a realistically large program, with
	for example, 50,000 lines, the programmer would probalbly
	never get to the enhancement."

	Pinto & Soloway "Providing the Requisite Knowledge Via Software
	Documentation," Proceedings of CHI, 1988. ACM, New York, p.257.

		-Brad Sherman (bks@ALFA.Berkeley.Edu)

------------
      "Hobgoblins have the consistency of small minds."

swilson%thetone@Sun.COM (Scott Wilson) (12/30/88)

In article <18621@agate.BERKELEY.EDU> bks@ALFA.berkeley.edu (Brad Sherman) writes:
>      "Hobgoblins have the consistency of small minds."

I believe the quote you're looking for is:

	"A foolish consistency is the hobgoblin of little minds."

Attributed to Emerson's Self-Reliance and recently featured in Reebok
commercials.  (No, I didn't know where it came from, Bartlett's Book of
Quotes comes in handy.)


--
Scott Wilson		arpa: swilson@sun.com
Sun Microsystems	uucp: ...!sun!swilson
Mt. View, CA

bdb@becker.UUCP (Bruce Becker) (12/31/88)

In article <83297@sun.uucp> swilson@sun.UUCP (Scott Wilson) writes:
+-----------------------
| In article <18621@agate.BERKELEY.EDU> bks@ALFA.berkeley.edu (Brad Sherman) writes:
| >      "Hobgoblins have the consistency of small minds."
| 
| I believe the quote you're looking for is:
| 
| 	"A foolish consistency is the hobgoblin of little minds."
| 
| Attributed to Emerson's Self-Reliance and recently featured in Reebok
| commercials.  (No, I didn't know where it came from, Bartlett's Book of
| Quotes comes in handy.)
| 
| Scott Wilson		arpa: swilson@sun.com
| Sun Microsystems	uucp: ...!sun!swilson
| Mt. View, CA
+-----------------------

	Let's get it straight once and for all please. The
	One True Quote is:


	"A foolish mind is the consistency of little hobgoblins."


	which is attributed to Gulliver.


Giggle,
-- 
   _  _/\	Bruce Becker	Toronto, Ont.
   \`o O|	Internet: bdb@becker.UUCP, bruce@gpu.utcs.toronto.edu
    \(")/	BitNet:   BECKER@HUMBER.BITNET
---mm-U-mm---	"The OSF is suffering from Penix envy" - Rocky Raccoon

bobmon@iuvax.cs.indiana.edu (RAMontante) (01/01/89)

	"A little foolishness consistently gobbles mine hob."

-- 
--  bob, mon	(bobmon@iuvax.cs.indiana.edu)
--  RAMontante,  Computer Science Dept.,  Indiana University,  Bloomington
--	"In this position, the skier is flying in a complete stall..."

wald-david@CS.YALE.EDU (david wald) (01/04/89)

What's a little more net volume?

In article <190@becker.UUCP> bdb@becker.UUCP (Bruce Becker) writes:
>In article <83297@sun.uucp> swilson@sun.UUCP (Scott Wilson) writes:
>| In article <18621@agate.BERKELEY.EDU> bks@ALFA.berkeley.edu (Brad Sherman) writes:
>| >      "Hobgoblins have the consistency of small minds."
>|
>| I believe the quote you're looking for is:
>|
>|      "A foolish consistency is the hobgoblin of little minds."
>>            -- Emerson's Self-Reliance
>
>  "A foolish mind is the consistency of little hobgoblins."
>         -- Gulliver

(quotes reformatted)

"A consistent hobgoblin minds little fools."
    -- A foolish hobgoblin with a consistent little mind

============================================================================
David Wald                                              wald-david@yale.UUCP
waldave@yalevm.bitnet                                 wald-david@cs.yale.edu
"A monk, a clone and a ferengi decide to go bowling together..."
============================================================================

al@gtx.com (Alan Filipski) (01/04/89)

In article <83297@sun.uucp> swilson@sun.UUCP (Scott Wilson) writes:
->In article <18621@agate.BERKELEY.EDU> bks@ALFA.berkeley.edu (Brad Sherman) writes:
->>      "Hobgoblins have the consistency of small minds."
->
->I believe the quote you're looking for is:
->
->	"A foolish consistency is the hobgoblin of little minds."
->
->Attributed to Emerson's Self-Reliance and recently featured in Reebok

Are you sure? I could swear it was something like 

   "awful itch consists in sieze daub gobble and afflict dumb hinds"

I think it's an anti-hunting slogan.

  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ( Alan Filipski, GTX Corp, 8836 N. 23rd Avenue, Phoenix, Arizona 85021, USA )
 ( {allegra,decvax,hplabs,amdahl,nsc}!sun!sunburn!gtx!al       (602)870-1696 )
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   "consistently gobbling little minds is a foolish hobby"