Path: utzoo!attcan!uunet!seismo!sundc!pitstop!sun!amdcad!ames!ncar!tank!oddjob!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.fortran Subject: Re: i++, i+=1, i=i+1 Message-ID: <13583@mimsy.UUCP> Date: 16 Sep 88 10:53:46 GMT References: <13566@mimsy.UUCP> <3629@lanl.gov> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 46 >In article <13566@mimsy.UUCP> I wrote a nice flowery description showing exactly why I say `i += 1' is superiour to `i = i + 1', and described it as follows: >>... 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 rather see `i += 1' than `i = i + 1'. In article <3629@lanl.gov> jlg@lanl.gov (Jim Giles) answers: >My english description of 'i = i + 1' _is_ "add 1 to i". the difference >between that and 'i += 1' is purely textual. Very well. Let us remove the `**' operator from FORTRAN, replacing it with the `POWER' intrinsic. The difference is purely textual. >... In other words, as far as functionality goes, '+=" doesn't do a >damn thing. Actually, it does, although it would not in FORTRAN. In C, given int *pickone() { static int a, b; return (rand()&1 ? &a : &b); } the expressions *pickone() += 1; and *pickone() = *pickone() + 1; mean very different things. But this is irrelevant. The key is that the C language has op= operators, so you can expect anyone reading C code to be familiar with them. Since they more concisely express the intended result, you should use them. The FORTRAN languages do not have op= operators, and you cannot expect anyone reading FORTRAN code to be familiar with them. While they more concisely express the intended result, you should not use them lest you confuse the reader. Similarly, the FORTRAN language has the `**' operator. It more concisely expresses exponentiation than C's `pow()' function. It should be used ... in FORTRAN, and not in C. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris