[GOODIE] Arithmetic assignments (+= and friends)

Andreas Raab Andreas.Raab at gmx.de
Tue Jun 18 15:54:56 UTC 2002


Richard,

> Urk.  So if I do
>     x := 3.
>     x += 1.
> it should affect the value (3) and ONLY the value, so after this
> x is still 3, and 3 is still unchanged because you can't 
> change numbers?

Right ;-) Notice that I wrote "if properly implemented" and
unfortunately for some of the examples (like the above) it just cannot
be properly implemented. E.g., if you take something like a "FloatArray
with: 3" in your example it would work just the way described.

> In the form
>     <lhs> += <rhs>
> What are the allowed forms for <lhs> and <rhs>?

See original message:
<lhs> - a variable name (for implementors that cannot properly implement
it)
<rhs> - any expression

> Can the effect be explained by a source to source transformation?

See original message:

	lhs := lhs perform: #+= with: rhs.

> Does the <lhs> (or its value, or whatever) have to support #+=?

Yes. See the original message and look at the changes.

> I'm rather unhappy about a += that isn't *automatically related*
> to +.  (Even more so about B2Color4Array that does have #+= but
> does not have #+.)

It's inherited from FloatArray. Look at FloatArray>>+

Cheers,
  - Andreas




More information about the Squeak-dev mailing list