Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!uwvax!oddjob!gargoyle!ihnp4!homxb!houxm!hropus!ka From: ka@hropus.UUCP (Kenneth Almquist) Newsgroups: comp.lang.c Subject: Re: Writing readable code (actually, assignment statement semantics) Message-ID: <1141@hropus.UUCP> Date: Sun, 5-Jul-87 17:53:24 EDT Article-I.D.: hropus.1141 Posted: Sun Jul 5 17:53:24 1987 Date-Received: Mon, 6-Jul-87 06:42:57 EDT References: <1158@copper.TEK.COM> <6858@auspyr.UUCP> <17171@cca.CCA.COM> <262@auvax.UUCP> <783@nu3b2.UUCP> Organization: Bell Labs, Holmdel, NJ Lines: 27 Let me give a little history here. In the mid 70's, there were two documents describing C: the C Language Tutorial and the C Reference Manual. The C Tutorial stated that the value of an assignment statement was the right hand side, and the C compiler agreed. When I read this, I was impressed with the attention to detail this showed. Unfortunately, I was not so attentive to detail, and failed to note that the C Reference Manual disagreed. So when the stdio library was written, I started writing, "char c; while ((c = getchar()) != EOF) ...", assuming that the test for EOF would work as the C Language Tutorial said it would. Eventually (e. g. around 1979 or 1980), the UNIX Support Group at Bell Labs noticed the discrepancy between the C Reference Manual and the C compilers, and modified the C compilers to agree with the Reference Manual. This generally made the object code produced by the compilers larger, and broke a bunch of existing code in subtle ways (the change was just made, not announced), but certainly the discrepancy between the documentation and the code had to be resolved some how. Probably the BSD Vax compiler is based upon an early version of the AT&T Vax compiler which predated the modifications. As you can probably tell, I would never have made the value of the assign- ment operator be the left hand side. But this is a minor matter compared with, say, the priority of the & and | operators, and Dennis Ritchie endorsed the left hand side approach in the C Reference Manual, even if he contradicted himself elsewhere. It seems a little late to re-fight the battle at this point. Kenneth Almquist