Hey,
I was just reading the discussion where William Cook is critiquing CTM. In this post, where he is contrasting Objects and ADTs, he says:
...the well-known problem of 'binary methods' in object-oriented programming. It is also one reason why numbers are hard to implement as objects: the operations +, *, / etc all require access to representations unless you are willing to give up a lot of performance. The way Smalltalk handles numbers is really fascinating, and not very well known.
Further down, he illustrates objects as follows:
The argument O is not the Client, the function is the Client:
Client = Fun{Container O}.... {O.get...} {O.put....} ... end.
It gets even more interesting when you have operations that take multiple object values, like "compare dictionary" or "append lists". Then you would have
Client2 = Fun{Container O1, Container O2}.... {O1.append(O2)...} {O2.compare(O1)....} ... end.
In this case the "class" of the two container objects O1 and O2 can be completely unrelated and everything will still work! This is a strong illustration of the power of objects. Again, see my paper on ADT vs OOP for more discussion. This is how numbers work in Smalltalk.
Oz makes me a bit cross-eyed, but this seems a pretty straight-forward use of OO. Hopefully someone can explain why binary operators are so fascinating in Smalltalk...
Cheers...
Recent comments
27 weeks 1 day ago
27 weeks 2 days ago
27 weeks 2 days ago
49 weeks 3 days ago
1 year 1 week ago
1 year 3 weeks ago
1 year 3 weeks ago
1 year 5 weeks ago
1 year 10 weeks ago
1 year 10 weeks ago