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