***** D method override mechanisms borked ******

Jari-Matti Mäkelä jmjmak at utu.fi.invalid
Sun Jun 25 12:47:12 PDT 2006


Lars Ivar Igesund wrote:
> Actually, Walter has stated in the past that if Java and C++ do something
> differently, he choose the C++ way. Now that almost nothing work in a way
> that anyone understand, I think it might be time to start over with OOP
> semantics that is best for D, no matter how it is done in C++, Java or C#.

That would be the best way to go. The primary goal would be to obey the
guidelines of language D and only after that some secondary goals like
complexity of the implementation (compiler, not application programs).

AFAIK the biggest problem with covariance is that derived classes reveal
too much "internal" functionality to the rest of the world. C++ fixes
this by hiding these members and Java does it by allowing access to
classes through different interfaces. IMHO the way Java does it is
overall much better since it does not generate runtime exceptions, when
used correctly. The drawback is that since the whole implementation of
the class is left open, it requires careful design when implementing
individual class level components. Another option is to use has-a
relationships where applicable.

The way c++ does it is much more stricter. It really denies all illegal
use, but needs to rely more on compile time checks. The problem here is
that the reference compiler does not support this functionality (yet, I
think). Another problem is that it might cause additional testing.

Well, in principle it's possible to support both approaches at the same
time, but I prefer the former approach myself. The only problem is that
interfaces in D cannot be easily used as "roles" without much explicit
casting. xs0 told in D.announce that it's possible to extend the
functionality of interfaces without any extra overhead at all (but it
would require more from the optimization logic of the compiler).

Ok, this might be a bit OT, but still I think these all are a bit
related. If Walter will do anything to "fix" these, I promise I will
shut up, stop complaining and go write some useful programs. :)

-- 
Jari-Matti



More information about the Digitalmars-d-bugs mailing list