From: "Hyman Rosen" <hyman.rosen@gmail.com>
Subject: Re: tagged record child: override constructor?
Date: 15 Sep 2005 06:19:40 -0700
Date: 2005-09-15T06:19:40-07:00 [thread overview]
Message-ID: <1126790380.573573.78220@g44g2000cwa.googlegroups.com> (raw)
In-Reply-To: 12v93t1k4i81i$.sm5jmg8q3lpk$.dlg@40tude.net
Dmitry A. Kazakov wrote:
> Which mistake? Again, it is solely the actual object's *type* which
> determines dispatch.
The mistake of not calling the overridden method of the actual
type of the object rather than of the declared type. In OO
programming, by-reference objects have two types, their declared
base type and their actual created type. In OO programming, it is
expected by the programmers that a call to a potentially overridden
function using a base by-reference object will dispatch to the
overridden function. If the language claims to support OO but then
makes it easy to call these methods in such a way that overriding
doesn't happen, and without warning, then the language has introduced
a dangerous trap. That is supposedly antithetical to the spirit of
Ada.
> It is 100% safe, intuitive and unambiguous.
It is not intuitive at all, except to people whose intuition has
been warped. It's just plain wrong.
> Ada is a typed language! Is C++ one?
It's the Ada language that has caused itself this problem. C++
requires that you clearly distinguish between a reference to an
object, a pointer to an object, and the object itself. Thus,
when you see a pointer or reference to a base class, you know
that the referee object may be of a derived class, and that
dispatching may take place. Ada, in trying to be clever about
hiding parameter passing mode from the programmer, and by not
supporting a distinguished dispatching object syntax, let itself
in for a trap.
> No. It calls B::g() which was inherited from A. I don't care if code of
> B::g() and A::g() share memory or not. They are different functions because
> their signatures are different.
No, they are the same function. If, for example, I included a static
variable within it, calls to A::g() and B::g() would see the same
variable. And for that matter, simply write this:
#include <iostream>
#include <ostream>
struct A { void g(); };
struct B : A { };
int main() { std::cout << (&A::g == &B::g) << "\n"; }
and you'll see whether the compiler thinks they're the same or not.
> It does not. It calls B::f() from B::g()
No. There is no B::g separate from A::g. Inherited functions are
not copies, they are the same function. There is no code you can
write which will demonstrate a difference.
next prev parent reply other threads:[~2005-09-15 13:19 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-13 5:58 tagged record child: override constructor? sean.gilbertson
2005-09-13 6:39 ` David Trudgett
2005-09-13 7:32 ` Dmitry A. Kazakov
2005-09-13 7:56 ` tmoran
2005-09-13 15:23 ` sean.gilbertson
2005-09-13 17:37 ` Martin Krischik
2005-09-13 19:29 ` Ludovic Brenta
2005-09-14 7:49 ` Dmitry A. Kazakov
2005-09-14 9:05 ` Maciej Sobczak
2005-09-14 13:20 ` Dmitry A. Kazakov
2005-09-14 13:52 ` Hyman Rosen
2005-09-14 16:47 ` Dmitry A. Kazakov
2005-09-14 17:16 ` Hyman Rosen
2005-09-14 20:20 ` Dmitry A. Kazakov
2005-09-14 20:34 ` Georg Bauhaus
2005-09-14 20:56 ` Hyman Rosen
2005-09-15 7:31 ` Dmitry A. Kazakov
2005-09-15 13:19 ` Hyman Rosen [this message]
2005-09-15 13:45 ` Maciej Sobczak
2005-09-15 17:45 ` Dmitry A. Kazakov
2005-09-15 18:54 ` Hyman Rosen
2005-09-16 9:32 ` Dmitry A. Kazakov
2005-09-16 14:52 ` Hyman Rosen
2005-09-16 15:33 ` Jean-Pierre Rosen
2005-09-16 18:37 ` Hyman Rosen
2005-09-16 21:03 ` Dmitry A. Kazakov
2005-09-16 21:33 ` Hyman Rosen
[not found] ` <98ox2x9xvj9z.1uh92dslhvt4g.dlg@40tude.net>
2005-09-17 12:47 ` Georg Bauhaus
2005-09-17 15:56 ` Dmitry A. Kazakov
2005-09-14 16:14 ` Martin Krischik
2005-09-14 16:57 ` Dmitry A. Kazakov
2005-09-14 18:35 ` Martin Krischik
2005-09-14 9:28 ` Alex R. Mosteo
2005-09-14 16:10 ` Martin Krischik
2005-09-13 9:33 ` Georg Bauhaus
2005-09-13 16:37 ` Jeffrey Carter
2005-09-13 18:55 ` Robert A Duff
2005-09-13 22:18 ` Jeffrey Carter
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox