Python 1.6 The balanced language

Suchandra Thapa ssthapa at harper.uchicago.edu
Fri Sep 1 05:10:22 CEST 2000


Neel Krishnaswami <neelk at brick.cswv.com> wrote:
>Suchandra Thapa <ssthapa at harper.uchicago.edu> wrote:
>> 
>> Actually I think clean is a pure functional oo language.  It's just
>> that being oo seems to imply that you have some state to your
>> objects.  Not sure anyone would get around this paradox.
>
>No, the distinguishing features of OO are that a) subtyping exists,
>and b) the types of objects are used to do dynamic dispatch. Mutable
>state is not necessary -- in both Dylan and Ocaml, it's common to
>write code in an "object-functional" style, with lots of objects but
>no mutation.

    I forgot about the existence of OCaml when I was writing the post
but ML has imperative features and so is not a pure functional language. 
The example you gave just illustrated dispatch on types. I haven't used 
ML or OCaml that  much but I believe that it can resolve having two functions
with the same name but different type signatures.  E.g. one len function
would have a List->Int signature and the other would have a SizedList->Int
signature and the compiler should be able to determine which to use based 
on the type information it has.  In ML, there are at least two  different + 
functions that either take two integers or two reals and add them.  The 
compiler has no problem determining which to use at compile time.  I don't
see what requires leaving the choice of len until runtime.  
    Incidentally, what do you mean by dynamic dispatch?  ML and its 
dialect OCaml are statically typed and the compiler chooses which function 
to call at compile time.  Would you consider OCaml to be OO then?  And isn't 
Dylan an imperative language but with first class  functions?
    But getting back to OO, I'm not sure how the essentials of OO that you 
put forward mesh with a pure functional approach.  In other words suppose I
had a method bar belonging to class foo.  How would I distinguish using 
foo.bar from using another function baz that took the same parameters and 
returned the same results?  It's possible to create such a baz by cutting 
and pasting the function body from bar.  I don't see what using objects 
gain in this context aside from some syntactic sugar.  Also what would the 
use be in declaring two objects of the same class?  They wouldn't behave any
differently.  




More information about the Python-list mailing list