Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!haven!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.fortran Subject: i++, i+=1, i=i+1 Message-ID: <13566@mimsy.UUCP> Date: 15 Sep 88 01:08:26 GMT References: <13547@mimsy.UUCP> <3568@lanl.gov> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 44 >In article <13547@mimsy.UUCP> I wrote: >>I do suggest, though, that no one use `i = i + 1' to increment. If you >>dislike `++', use `i += 1'. When you mean `add one to i', why not *say* >>it? In article <3568@lanl.gov> jlg@lanl.gov (Jim Giles) writes: >'i = i + 1' _does_ say it!!! Indeed, in a certain sense---if one examines the semantics and considers the language definition, always, of course, keeping in mind the actions and situations and possibilities, and remembering all there is to contemplate upon, why, then, certainly---it does not say anything other than what it should say, which is to say, not to do anything other than to add one to i. Have I, perhance, managed to communicate with these words, these sentences, these paragraphs, the sense in which I mean to imply that `add one to i' and `take i, add one, and put it back' are, while they are certainly congruent in some aspects, and in ultimate true meaning identical, not at all the same? >Any compiler which generates different code for 'i = i + 1', 'i += 1', >and 'i++' is a certifiably _stupid_ compiler. Agreed. >Those three examples are semantically _identical_, their syntactic difference >is a textual convenience - at best. Also agreed. Convenience, however, makes all the difference. I, as a reader, would much rather see as an English description the phrase `add 1 to i' than `evaluate i, evaluate the integer constant 1, add the values together, and store the result in the location named by i'. Likewise, I would much rather read `i += 1' than `i = i + 1'. For such a trivial expression, the difference in convenience is minimal. But what about -- not in any particular language intensity(l1, II, l[I[1]]) += factors[Il[l1+I[II]]] Here the notational conveniece is quite significant. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris