Am 2011-04-20 um 22:18 schrieb Ted F.A. van Gaalen:

> Thanks Tobias and Igor for your thoughts about this increment/decrement theme.
> @Tobias: what kind of side effect(s) are you talking about? I don't
> understand, sorry.

No problem, I wrote a bit complicated.
What I mean is that 
        i++
instructs the object ‘i’ to change its state, ie, increment
itself.
However, the Object in ‘i’ is meant to be an 
integer. So, how to interpret that? say, ‘i’ is 5.
Essentially, 
        i++
says
        ‘five, change your state to be six’
But that would imply, because all integers are the respecive same
over the image, that all fives are suddenly sixes.

The point is,
in C, variables denote memory cells, and it is a common
operation to say ‘memory cell, increment your content by one’,
whereas in Smalltalk, a variable denotes an object and 
such an increment is rather senseless on integer objects.

In other words, each integer in a Smalltalk image is
a kind of Singleton.
(       as 
        1 = 1 " => true"
        1 == 1 " => true"
)
Hence,
| a b |
a := 1.
b := 1.
a = b " => true (a and b have the same content)".
a == b "=> true (ie, they are the indentical object)".

"but"

a ++. "hypothetical"
a = b "=> ??, probably false".
a == b " => ??, can't think of that".


So Long,
        -Tobias










Reply via email to