Version française
Home     About     Download     Resources     Contact us    
Browse thread
C++/C# inheritance is bad?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Stefano Zacchiroli <zack@u...>
Subject: Re: [Caml-list] C++/C# inheritance is bad?
On Sat, Jan 17, 2009 at 09:07:19AM -0500, Kuba Ober wrote:
>> I thought he was talking about the effects of runtime polymorphism on
>> static code analysis. You can't tell which method is invoked if the
>> method is virtual.
> That's fine, because if your code is written well it doesn't matter at
> all which one it is. All you care about is the interface and not the
> particular implementation -- assuming that all implementations adhere

It seems to me that you are implicitly assuming that the interface is
expressive enough to encode all the good properties you want your code
to obey to, while it is not the case, especially for mainstream OO
languages whose type systems are waaaaaaay too lightweight.

Hence, the reference to static analysis above was, AFAICT,
specifically meant to prove properties which are not encoded by the
method interfaces, and hence depend on the method implementations.

And precisely that you are screwed, because you need to know which
method is actually called, which is harder with ad-hoc polymorphism.


Somebody mentioned in this thread that the same problem has to be
faced with functors. That is true for the casual look at the code, but
at least in OCaml the functor language can be completely expanded at
compile time (or at least it was at the time of ocamldefun [1], unless
I'm mistaken).

Cheers.

[1] http://www.lri.fr/~signoles/ocamldefun/index.en.html

-- 
Stefano Zacchiroli -o- PhD in Computer Science \ PostDoc @ Univ. Paris 7
zack@{upsilon.cc,pps.jussieu.fr,debian.org} -<>- http://upsilon.cc/zack/
Dietro un grande uomo c'è ..|  .  |. Et ne m'en veux pas si je te tutoie
sempre uno zaino ...........| ..: |.... Je dis tu à tous ceux que j'aime