[Edu-sig] An OOP view of the "number" concept

Christian Mascher christian.mascher at gmx.de
Sun Apr 22 14:58:40 CEST 2007


Hi Kirby,

>>3 .__add__(5)
>>    
>>
>>>3 .__add__(5)
>
>8
>
>
>Of course this still looks strange to people who grew
>up in the 1900s (as I did) and think in a different paradigm.
>
>In the old way of thinking, operations were not included
>in our type definitions. The idea of "adding" was
>somehow independent of the set theory definitions
>(since dispensed with) of integers for example.
>

I still recall the moment, when - while learning some smalltalk (after I 
knew Python) - one expression really impressed me:
<smalltalk>
2 sin
</smalltalk>
Because in smalltalk nearly all expressions are message sends of the syntax
receiver message
this would mean the same as
2.sin()
in a python-like-syntax. So 2 is an object, which you can ask to give 
you its sine-value. This is classical smalltalk-80.
"Everything is an object" means more to me since that moment.

It is interesting how they do this in smalltalk, for instance, you can 
easily put different kinds of number types on the left side- like "2.0 
sin" gives you the same value for a float type.

Actually in Python, dot-notation breaks down with this case:
2.0.sin() ???
I just noticed that. Perhaps one of the reasons smalltalk doesn't use 
the dot.

Greetings

Christian




More information about the Edu-sig mailing list