[GOODIE] Arithmetic assignments (+= and friends)
Lex Spoon
lex at cc.gatech.edu
Wed Jun 19 14:36:31 UTC 2002
"Richard A. O'Keefe" <ok at cs.otago.ac.nz> wrote:
> (4) The complaints by several people that writing x := x + y just isn't
> a big deal miss the point. The point is to have notational
> uniformity between updating an object (which is the value of x)
> that can increment itself and updating a variable (whose value
> is immutable and cannot increment itself).
>
This is a huge difference, and the two operations shouldn't be made to
look the same. Updating a value is bread and butter in most languages.
Rebinding a variable to a new value is a very big deal, and is even
outlawed in many languages.
Besides, won't a programmer like to know which operation is happening?
x := <whatever>.
y := x.
y mutateByAdding: 3
Then I want x to change no matter what <whatever> is. If I do:
x := <whatever>.
y := x.
y := y + 3.
Then I *don't* want x to change, no matter what <whatever> is. How
often will you not care which interpretation is used? If you have any
statements like the "y := x" above, then getting the wrong
interpretation will probably mess up your program.
-Lex
More information about the Squeak-dev
mailing list
|