From: dmitry@elros.cbb-automation.de (Dmitry A. Kazakov)
Subject: Re: Merits of re-dispatching [LONG]
Date: Tue, 12 Feb 2002 08:32:55 GMT
Date: 2002-02-12T08:32:55+00:00 [thread overview]
Message-ID: <3c68ceeb.88774578@News.CIS.DFN.DE> (raw)
In-Reply-To: 1013192956.289787@master.nyc.kbcfp.com
On Fri, 8 Feb 2002 13:30:04 -0500, "Hyman Rosen" <hyrosen@mail.com>
wrote:
>"Dmitry A. Kazakov" <dmitry@elros.cbb-automation.de> wrote in message news:3c6392e8.2400843@News.CIS.DFN.DE...
>> First C++ does not make any difference between class wide and specific
>> objects. The same type B is a class wide in B::f () and specific in
>> B::~B (). So the difference in how B::f and B::~B are dealing with
>> calls to g(). This is IMO bad.
>
>This is an incorrect view of what is happening. The type is class-wide
>in both B::f and B::~B. Calls to B::g are dispatching in both. It's just
>that while B::~B is running, the actual type of the object is B, so any
>dispatching happens according to B's virtual functions, even if the B
>part happened to be part of a derived class.
That is one of several possible interpretation of what happens in C++
using Ada terms. However, I prefer mine, because it is consistent with
the fact that the type tag [= vtab] is constant, thus the actual
specific type is also constant. Like in Ada it is only a view
conversion.
>struct A { virtual void foo() { cout << "A::foo\n"; }void call_foo() { foo(); } virtual ~A() { call_foo(); } };
>struct B : A { void foo() { cout << "B::foo\n"; } ~B() { call_foo(); } }
>struct C : B { void foo() { cout << "C::foo\n"; } ~C() { call_foo(); } };
>
>When a C object is destructed, it will print "C::foo"., "B::foo", "A::foo".
>
>> type is already *known*. Thus there is no need in [re-]dispatching. A
>> call to g() can be statically resolved.
>
>As in my example, not if the object is passed to some other routine which
>makes the dispatching call.
When you pass it to some other routine an implicit specific->class
wide conversion happens, so the routine can dispatch again. An Ada 95
equivalent would be:
procedure Y (A : in out Object'Class);
procedure X (A : in out Object) is
begin
Y (A'Class (A));
end X;
Exactly this behaviour is IMO unsafe.
Regards,
Dmitry Kazakov
next prev parent reply other threads:[~2002-02-12 8:32 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-02-07 10:26 Merits of re-dispatching [LONG] Dmitry A. Kazakov
2002-02-07 15:03 ` Hyman Rosen
2002-02-08 1:29 ` Matthew Heaney
2002-02-08 9:16 ` Dmitry A. Kazakov
2002-02-08 18:30 ` Hyman Rosen
2002-02-09 0:10 ` Matthew Heaney
2002-02-12 8:32 ` Dmitry A. Kazakov [this message]
2002-02-12 21:37 ` Hyman Rosen
2002-02-13 9:29 ` Dmitry A. Kazakov
2002-02-13 14:32 ` Hyman Rosen
2002-02-13 19:58 ` Dave Harris
2002-02-14 15:06 ` Dmitry A. Kazakov
2002-02-16 12:10 ` Dave Harris
2002-02-18 8:57 ` Dmitry A. Kazakov
2002-02-18 19:47 ` Merits of re-dispatching Dave Harris
2002-02-19 9:20 ` Dmitry A. Kazakov
2002-02-21 5:49 ` Hyman Rosen
2002-02-21 9:04 ` Dmitry A. Kazakov
2002-02-21 18:17 ` Hyman Rosen
2002-02-22 9:21 ` Dmitry A. Kazakov
2002-02-22 16:59 ` Hyman Rosen
2002-02-25 8:51 ` Dmitry A. Kazakov
2002-02-08 23:51 ` Merits of re-dispatching [LONG] Matthew Heaney
2002-02-12 9:02 ` Dmitry A. Kazakov
2002-02-07 23:40 ` Nick Roberts
2002-02-08 8:56 ` Dmitry A. Kazakov
2002-02-08 1:06 ` Matthew Heaney
2002-02-08 9:48 ` Dmitry A. Kazakov
2002-02-09 0:16 ` Matthew Heaney
2002-02-08 18:10 ` Hyman Rosen
2002-02-09 0:41 ` Matthew Heaney
2002-02-08 18:33 ` Nick Roberts
2002-02-09 4:07 ` Nick Roberts
2002-02-12 10:13 ` Dmitry A. Kazakov
2002-02-14 20:57 ` Tucker Taft
2002-02-15 15:43 ` Dmitry A. Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox