garys@bunker.UUCP (Gary M. Samuelson) (08/27/85)
> I put null loop-bodies on a separate line like in the following > example. > > while (eatup() != '\n') > ; Putting the semi-colon on a separate line does help make it clear that the body of the loop is intentionally null, but what I like even better is: while( eatup() != '\n' ) continue; Comments? Gary Samuelson
driehuis%hlerul5.BITNET@Berkeley (08/28/85)
Gary M. Samuelson <garys@bunker.uucp> writes: >> I put null loop-bodies on a separate line like in the following >> example. >> >> while (eatup() != '\n') >> ; > >Putting the semi-colon on a separate line does help make it clear >that the body of the loop is intentionally null, but what I like >even better is: > > while( eatup() != '\n' ) > continue; > >Comments? Yes. I am not fond of using continue if it is not necessary to do so. All loop-modyfying statements require an additional effort to read - at least, for me. Neither do I like the suggesion I saw in info-c, that read something like > while (function() != READY) { > } The reason why is quite prosaic: when I edit an existing file into something else, with cutting, pasting, and deleting, sometimes (no more than once a week :=)) a line or even a block of text gets lost, leaving embraced white space. My first reaction to seeing braces, embracing nothing, is: oops... been too hastily with the delete-line key. The convention to use a period on a line by itself is sufficient to recognise at first sight: "this is a null statement".
coltoff@burdvax.UUCP ( Joel Coltoff) (08/30/85)
<<>> My approach is to explicitly spell it out with a comment. Sometimes they are the only comments in the program while ( eatup() != '\n' ) /* NULL BODY */; - Joel Coltoff {prseby,sdcrdcf,psuvax1}!burdvax!coltoff
weltyrp@rpics.UUCP (Richard Welty) (08/31/85)
> > I put null loop-bodies on a separate line like in the following > > example. > > > > while (eatup() != '\n') > > ; > > Putting the semi-colon on a separate line does help make it clear > that the body of the loop is intentionally null, but what I like > even better is: > > while( eatup() != '\n' ) > continue; > I personally like to use {} in all cases ... thus: while( eatup() != '\n'){} or while( eatup() != '\n') {} or even while( eatup() != '\n') { } By using the {} all the time, even for null cases, I insure that things like if( cond); don't happen ... -- Rich Welty (I am both a part-time grad student at RPI and a full-time employee of a local CAE firm, and opinions expressed herein have nothing to do with anything at all) CSNet: weltyrp@rpi ArpaNet: weltyrp.rpi@csnet-relay UUCP: seismo!rpics!weltyrp
cottrell@NBS-VMS.ARPA (COTTRELL, JAMES) (10/08/85)
/* > The reason I don't like: > > if(condition) { > s1; > s2; > } > can be shown by the following source: > > if (onelock(pid, tempfile, file) == -1) { > /* lock file exists */ > /* get status to check age of the lock file */ > ret = stat(file, &stbuf); > if (ret != -1) { > time(&ptime); > if ((ptime - stbuf.st_ctime) < atime) { > /* file not old enough to delete */ > return(FAIL); > } > ------------------------------------------------------------------------------ > } > ret = unlink(file); > ret = onelock(pid, tempfile, file); > if (ret != 0) > return(FAIL); > } > stlock(file); > > When I listed the file out, the page break was right where the dashed line is. Sorry, no dice. First off, the page break comes there regardless of how the `if' lines are formatted. Second off, what is the page break doing there anyway? Don't you know about Form Feeds? Funxions on one page please. > > Why do you like this style? This seems to indicate that > >the braces are associated in your mind with the enclosed statements. > > You seem to have answered your own question. What else are the braces related > to if not the enclosed statements? Note the following, which has nothing to do > with if's, while's, for's, or do's. > > main() > { > int i = 42; > float foo = 3.14159; > > printf("Starting program\n"); > printf("i = %d, foo = %f\n",i,foo); > > { /* Truly local variables */ > static char *foo = "What is the meaning of life?"; > double i = 1.414; > > printf("Another message\n"); > printf("i = %f, foo = %s\n",i,foo); > } > /* Back to the old variables */ > > printf("Yet another message\n"); > printf("i = %d, foo = %f\n",i,foo); > exit(0); > } How many people axually do this? I mean use nested blox? Most people use braces only where necessary. I have seen the trick #define save(x) { int save; save = x; #define restore(x) x = save; } which make use of this technique, but I feel nested variables (which usurp the scope of more global variables) are a relatively bad practice. If it's big enuf for it's own scope, it probably should be a funxion. jim cottrell@nbs */ ------
bc@cyb-eng.UUCP (Bill Crews) (10/09/85)
> > > Why do you like this style? This seems to indicate that > > >the braces are associated in your mind with the enclosed statements. > > > > You seem to have answered your own question. What else are the braces related > > to if not the enclosed statements? Note the following, which has nothing to do > > with if's, while's, for's, or do's. > > > > main() > > { > > int i = 42; > > float foo = 3.14159; > > > > printf("Starting program\n"); > > printf("i = %d, foo = %f\n",i,foo); > > > > { /* Truly local variables */ > > static char *foo = "What is the meaning of life?"; > > double i = 1.414; > > > > printf("Another message\n"); > > printf("i = %f, foo = %s\n",i,foo); > > } > > /* Back to the old variables */ > > > > printf("Yet another message\n"); > > printf("i = %d, foo = %f\n",i,foo); > > exit(0); > > } > > How many people axually do this? I mean use nested blox? Most people use > braces only where necessary. > > jim cottrell@nbs Do I understand you to say that, because a language construct is not often used, one should pretend it isn't part of C and use a conflicting conceptual model? Come on! Besides, it is used every time you have an if, while, do while, or for followed be a compound statement (a block); AND ever time you define a function. Let's not quibble over whether some variables happen to be declared or not. -- / \ Bill Crews ( bc ) Cyb Systems, Inc \__/ Austin, Texas [ gatech | ihnp4 | nbires | seismo | ucbvax ] ! ut-sally ! cyb-eng ! bc
rlk@chinet.UUCP (Richard L. Klappal) (10/10/85)
In article <1963@brl-tgr.ARPA> cottrell@NBS-VMS.ARPA (COTTRELL, JAMES) writes: ... >there anyway? Don't you know about Form Feeds? Funxions on one page please. ---------------------------------------------------? > >How many people axually do this? I mean use nested blox? Most people use ------------------?------------------------------------? >If it's big enuf for it's own scope, it probably should be a funxion. ----------------?------------------------------------------------? > > jim cottrell@nbs >*/ >------ Would someone please : 1> Send him a spelling checker? 2> Get him a CRT instead of a 110 baud tty 3> fix the 'C', 'K', & 'T' keys on his terminal? 4> ALL OF THE ABOVE? -- Richard Klappal UUCP: ..!ihnp4!chinet!uklpl!rlk | "Money is truthful. If a man MCIMail: rklappal | speaks of his honor, make him Compuserve: 74106,1021 | pay cash." USPS: 1 S 299 Danby Street | Villa Park IL 60181 | Lazarus Long TEL: (312) 620-4988 | (aka R. Heinlein) -------------------------------------------------------------------------
preece@ccvaxa.UUCP (10/10/85)
> /* Written 5:36 pm Oct 9, 1985 by rlk@chinet.UUCP in ccvaxa:net.lang.c */ > Would someone please : > 1> Send him a spelling checker? > 2> Get him a CRT instead of a 110 baud tty > 3> fix the 'C', 'K', & 'T' keys on his terminal? > 4> ALL OF THE ABOVE? ---------- Thou shalt not carp at a Usenet author's usage. In this particular instance it would be socially acceptable to point out INCONSISTENCIES (use of 'cks' instead of 'x' somewhere), but NOT to complain about the author's personal style. No style wars in technical newsgroups! -- scott preece gould/csd - urbana ihnp4!uiucdcs!ccvaxa!preece
gwyn@BRL.ARPA (VLD/VMB) (10/13/85)
Maybe this will help (but don't hold your breath): spelled x => ks sound as in "example" => ek sample spelled ct => kt sound as in "enacted" => enak ted spelled function => sounds like funk tion NOT funk sion therefore NOT spelled funxion (unfortunately for this example, tion => sounds like tchun which is very close to sounding like shun) Enunciate more precisely, please.
rlk@chinet.UUCP (Richard L. Klappal) (10/15/85)
since I started it, I suggest we move this discussion to net.followup or net.flame -- Richard Klappal UUCP: ..!ihnp4!chinet!uklpl!rlk | "Money is truthful. If a man MCIMail: rklappal | speaks of his honor, make him Compuserve: 74106,1021 | pay cash." USPS: 1 S 299 Danby Street | Villa Park IL 60181 | Lazarus Long TEL: (312) 620-4988 | (aka R. Heinlein) -------------------------------------------------------------------------
ron@brl-sem.ARPA (Ron Natalie <ron>) (10/15/85)
> Maybe this will help (but don't hold your breath): > > spelled x => ks sound as in "example" => ek sample > spelled ct => kt sound as in "enacted" => enak ted > > spelled function => sounds like funk tion > NOT funk sion therefore NOT spelled funxion > (unfortunately for this example, tion => sounds like tchun > which is very close to sounding like shun) > > Enunciate more precisely, please. Sorry to burst your bubble Doug, but FUNCTION is pronounced fungk'shen according to my dictionaries (the e is really a schwa). The -tion and -sion suffixes in English are pronounced the same way. Although, the cute spellings always get on my nerves. -Ron
tombre@crin.UUCP (Karl Tombre) (10/22/85)
Concerning Jim's style: OK perhaps we shouldn't bother with the way people are using the english language in technical groups, but please keep in mind that the net is international, and that we poor guys from a foreign country, who have learnt english at school and who may have trouble finding the right way for writing an english word, are rather confused when an american spells *SO MANY WORDS* in a different way. Seeing some of Jim's entries, I really asked myself: "Is this really the right way of writing this word? I always thought it was that other way..." And then you americans are giving us bad habits. Shame on you!!! -- --- Karl Tombre @ CRIN (Centre de Recherche en Informatique de Nancy) UUCP: ...!vmucnam!crin!tombre or ...!inria!crin!tombre COSAC: crin/tombre POST: Karl Tombre, CRIN, B.P. 239, 54506 VANDOEUVRE CEDEX, France "Car le plus lourd fardeau, c'est d'exister sans vivre." (Victor Hugo)
days@glasgow.glasgow.UUCP (Judge Dredd) (10/22/85)
> variant spelling of connection, which has pretty much the same sound > as function, so it's not that far off. For all I know 'funxion' > may be a recognized spelling in Britain (where 'connexion' is > more common than in the US). Arggggh, It's you lot that can't spell, not us :-) -- Stephen Day, Comp Sci Dept, University of Glasgow, Scotland seismo!mcvax!ukc!glasgow!days The Surgeon General has assertained that not having a Disclaimer here can be HAZARDOUS TO YOUR WEALTH
weltyrp@rpics.UUCP (Richard Welty) (10/26/85)
> Karl Tombre @ CRIN (Centre de Recherche en Informatique de Nancy) writes: > > Concerning Jim's style: > > OK perhaps we shouldn't bother with the way people are using the > english language in technical groups, but please keep in mind that the net > is international, and that we poor guys from a foreign country, who have > learnt english at school and who may have trouble finding the right way for > writing an english word, are rather confused when an american spells *SO > MANY WORDS* in a different way. Seeing some of Jim's entries, I really asked > myself: "Is this really the right way of writing this word? I always thought > it was that other way..." And then you americans are giving us bad habits. > Shame on you!!! > For those who do not speak english as a first language, might I recommend trying to get a copy of Strunk & White, "The Elements of Style". This excellent little book should be read by all who attempt to write English (including Jim). They even have a small section about people who write the way that Jim writes. To relate this back to the fact that this is in a technical discussion, I will point out that Kernighan and Plauger's "The Elements of Programming Style" was deliberately patterned after Strunk and White. This, of course, is another book that all should read. -- Rich Welty "P. D. Q.'s early infancy ended with a striking decision; at the age of three, P. D. Q. Bach decided to give up music" - Prof. Peter Schickele, from "The Definitive Biography of P. D. Q. Bach" CSNet: weltyrp@rpics ArpaNet: weltyrp.rpics@csnet-relay UUCP: seismo!rpics!weltyrp
jsdy@hadron.UUCP (Joseph S. D. Yao) (11/03/85)
In article <200@rpics.UUCP> weltyrp@rpics.UUCP (Richard Welty) writes: >For those who do not speak english as a first language, might I recommend >trying to get a copy of Strunk & White, "The Elements of Style". This >excellent little book should be read by all who attempt to write English >(including Jim). They even have a small section about people who write the >way that Jim writes. For those who d o speak english as a first language, might I recommend trying to get a copy of Strunk & White? ;-) (!!!) -- Joe Yao hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}