Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!brl-adm!brl-smoke!smoke!rbj@icst-cmr From: rbj@icst-cmr (Root Boy Jim) Newsgroups: net.lang.c Subject: Re: Precedent for use of = Message-ID: <2023@brl-smoke.ARPA> Date: Tue, 8-Jul-86 11:45:48 EDT Article-I.D.: brl-smok.2023 Posted: Tue Jul 8 11:45:48 1986 Date-Received: Wed, 9-Jul-86 02:14:06 EDT Sender: news@brl-smoke.ARPA Lines: 63 > They already did. Let me quote K&R, p.17: > > The double equals sign == is the C notation for "is equal to" (like > Fortrans's .EQ.). This symbol is used to distinguish the equality > test from the single = used for assignment. Since assignment is about > twice as frequent as equality testing in typical C programs, it's > appropriate that the operator be half as long. And since `if' clauses are twice as frequent as `else' clauses, the former token should be half the length of the latter :-) > Personally, I still prefer := for assignment and = for equality over = and ==. Then you would mistype `a = b' instead of `a := b'. > I also think that the keystroke argument is ridiculous (flames to /dev/null). Me too. Since most statements are one to a line, requiring `;' is kind of redundant. Make newline imply `;' unless the statement is incomplete, such as a control statement or unbalanced parens, or dyadic operators at the end of line. Use `;' to jam multiple statements on one line. As always, `\' newline is ignored. > The problem with = and == is further aggravated by the > fact that in C an assignment is an expression and not a statement, so > that code like Since this feature is only in C, LISP, APL, (& others I don't know about) and not in FORTRAN, BASIC, PASCAL, COBOL, PL/I (?), two separate operators are required in the formers, and only suggested in the latters. One FORTARN compiler (DEC?) (U Md.'s RALPH?) would even convert `IF (A = B)' into `IF (A .EQ. B)' for you. > > if (i = 0) { > /* do something */ > } > else { > /* do something else */ > } > > is legal C and usually /* does something else */ than you expected :-) Yes, only one branch (or none), or loop forever (or not at all). I find these easy to fix. > Despite that, I would never call Messrs K&R idiots, as Niklaus Wirth has > been labeled in a recent message (not the one I am responding to): > I think both C and Pascal have been reasonable designs of programming > languages and important contributions to the computing community. Aw, c'mon, is that all the response my statement generated. Let me try again. Dennis Ritchie is like Jerry Garcia: subtle and sweet, while Nickels Worth is like Jimmy Page*: obvious and without any taste. > Robert Marti, Sun Microsystems, Inc. > > UUCP: ...{cbosgd,decvax,decwrl,hplabs,ihnp4,pyramid,seismo,ucbvax}!sun!rmarti > ARPA: rmarti@sun.com (Root Boy) Jim Cottrell Is it clean in other dimensions? * if you are a `Led Head', then substitute `Mark Farner' for `Jimmy Page'.