Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!bionet!ames!hc!lanl!jlg From: jlg@lanl.gov (Jim Giles) Newsgroups: comp.lang.c Subject: Re: Statement terminators Message-ID: <13292@lanl.gov> Date: 8 May 89 22:09:59 GMT References: <2296@mit-caf.MIT.EDU> Organization: Los Alamos National Laboratory Lines: 40 From article <2296@mit-caf.MIT.EDU>, by vlcek@mit-caf.MIT.EDU (Jim Vlcek): > You see, we have to _read_ the source code we write, and having extra > characters in the source to escape newlines adds clutter which impedes > one's recognition of the source text. Consider: in normal printed > text, a carriage return is simple whitespace. Why should it be > different in source code? It should be different in source code because programming is a _different_ process than generating normal printed text (or do you also start every program statement with a capital letter, etc?). I'm glad _I_ don't have to read your source code. I _REALLY_HATE_ it when somebody squashes all their source together. > And imagine this > Everytime one starts a new statement, one must insert a carriage\ > return > No matter how short it is > No matter how annoying that gets > Get the point? And imagine this: somebody writing code the way Jim Vlcek is recommending- printd(n) /* print n in decimal*/ int n; if (n<0) {putchar('-');n= -n;} i=0; do {s[i++]=n%10+'0'; /* get next char */ } while ((n/=10) >0); /* discard it */ while (--i >= 0) putchar(s[i]);} printd(n) /* print n in decimal (recursive) */ int n; {int i; if (n<0) {putchar ('-'); n= -n;} if ((i=n/10) !=0) printd(i); putchar(n%10+'0');} Get the point? _NOBODY_ writes _PROGRAMS_ this way. _EVERYBODY_ uses the end-of-line as _MORE_ than _just_ whitespace. In fact, almost everyone begins each program statement on a separate line. The design criterion of relevance here is that the most common usage should have the simplest syntax - that is, let the end-of-line be a statement terminator (keep semicolon also, this allows multiple statements per line if desired). The _less_ common usage (by a _long_ shot) is continuation of statements across lines - it is _this_ case that should have the extra syntax of an escaped carriage return. The extra syntax is _not_ clutter, it serves to point out explicitly the unusual occurrance of a continued line. (Program above was both examples from page 85 of K&R.)