Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!sri-spam!mordor!lll-tis!ptsfa!ihnp4!alberta!auvax!rwa From: rwa@auvax.UUCP (Ross Alexander) Newsgroups: comp.lang.c Subject: Re: Writing readable code Message-ID: <263@auvax.UUCP> Date: Mon, 6-Jul-87 12:00:15 EDT Article-I.D.: auvax.263 Posted: Mon Jul 6 12:00:15 1987 Date-Received: Wed, 8-Jul-87 00:51:15 EDT References: <1158@copper.TEK.COM> <6858@auspyr.UUCP> <17171@cca.CCA.COM> <225@amanue.UUCP> Organization: Athabasca U., Alberta, Canada Lines: 31 Summary: I withdraw the suggestion (whoops!) In article <225@amanue.UUCP>, jr@amanue.UUCP (Jim Rosenberg) writes: > In article <262@auvax.UUCP>, rwa@auvax.UUCP (Ross Alexander) writes: > > The following discussion is all relative to [... and other maunderings] I withdraw! I recant! assignment-produces-an-implicit-cast, see K&R Appendix A, 7.14! I wuz rong!!! Please let's save net bandwidth (and my shattered ego). Gads. Everybody's an expert [grumble mutter rhubarb rhubarb rhubarb]. As an aside (I _DO NOT_ propose this be made standard), just as a very personal, off-the-cuff-remark, the rule does seem like a bit of a lose. There must be a good reason for it. What is it? After all, after the store the original value is still sitting around in a register (of course you can dream up architectures where this is not so, yes, I know, I know ), Anyway, it annoys me to see what I think of as a side-effect (the store) throwing away perfectly useful information - and then the first thing that happens after the store is the char expression is re-promoted to int! Waste motion, waste motion... Yes, a clever compiler will do the comparison char-to-char to avoid doing the promotion, because it's equivalent (in a formal sense) to the int-to-int case, but the whole original point was that the assignment introduces a bug through the loss of the out-of-band value (EOF). So as Guy Harris observes, the vax 4.2bsd compiler generates incorrect code. Yet it seems to me that this code is more robust that the `correct' code :-). This is something for the designers of P to think about, I guess. However, the semantics of C are perfectly clear on this, and I was wrong. ...!ihnp4!alberta!auvax!rwa Ross Alexander @ Athabasca University