Not fully OO ?

Aaron "Castironpi" Brady castironpi at gmail.com
Sat Sep 20 17:07:26 EDT 2008


On Sep 20, 3:22 pm, Kay Schluehr <kay.schlu... at gmx.net> wrote:
> On 20 Sep., 18:33, Bruno Desthuilliers
>
> <bdesth.quelquech... at free.quelquepart.fr> wrote:
> > The following definitions are AFAIK the only commonly accepted
> > definitions about OO:
>
> > 1/ an object is defined by identity, state and behaviour
> > 2/ objects interacts by sending messages each other
> > 3/ an OO program is made of interacting objects
>
> > I let you find out whether Python meets these 3 definitions - and if
> > Java does (hint : in Python, everything you can bind to a name is an
> > object - this is not true in Java or C++).
>
> This is correct but it detracts from a more general problem of
> language "paradigms".
>
> Assume you type
>
> >>> 2+2
>
> 4
>
> Now you are free to interpret this as a simple, primitive arithmetic
> operation but you can also claim that 2 sends an __add__ message to 2.
> Hereby the state of the 2 objects are not altered but a new 4 object
> is created. OO babble is more impressive isn't it?
>
> Actually it is simply wrong in the mentioned case and here is the
> proof:
>
> def foo():
>     return 2+2
>
> import dis
> dis.dis(foo)
>
>   2           0 LOAD_CONST               2 (4)
>               3 RETURN_VALUE
>
> OO is a heuristic method used to understand the semantics of a
> programming language. It can also inspire language design but as
> you've rightly said: jugde yourself and see how far you get with it.
>
> Applying OO on interpreter level is by no means a sign of a high
> quality implementation whereas structuring programs in the large will
> likely benefit from class based organization and encapsulation. Of
> course one can also reverse the value hierarchy and find perverse joy
> in having a pure OO language but apply monkey patching everywhere. I
> suppose you know which language I'm talking about...

It sounds like you think that you -can- write OO programs in Python,
but you don't have to.  I agree.



More information about the Python-list mailing list