From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7a180be12347b9d3 X-Google-Attributes: gid103376,public X-Google-Thread: 1108a1,7a180be12347b9d3 X-Google-Attributes: gid1108a1,public X-Google-ArrivalTime: 2002-02-19 01:20:09 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news.tele.dk!small.news.tele.dk!130.133.1.3!fu-berlin.de!uni-berlin.de!tar-alcarin.cbb-automation.DE!not-for-mail From: dmitry@elros.cbb-automation.de (Dmitry A. Kazakov) Newsgroups: comp.lang.ada,comp.object Subject: Re: Merits of re-dispatching Date: Tue, 19 Feb 2002 09:20:06 GMT Message-ID: <3c721028.221281@News.CIS.DFN.DE> References: <3c70b935.501062@News.CIS.DFN.DE> NNTP-Posting-Host: tar-alcarin.cbb-automation.de (212.79.194.111) X-Trace: fu-berlin.de 1014110406 3027336 212.79.194.111 (16 [77047]) X-Newsreader: Forte Free Agent 1.21/32.243 Xref: archiver1.google.com comp.lang.ada:20117 comp.object:34662 Date: 2002-02-19T09:20:06+00:00 List-Id: On Mon, 18 Feb 2002 19:47 +0000 (GMT Standard Time), brangdon@cix.co.uk (Dave Harris) wrote: >dmitry@elros.cbb-automation.de (Dmitry A. Kazakov) wrote (abridged): >> > This should produce B.Foo B.Foo A.Foo A.Foo. >> >> With my correction it will produce: >> >> B.Foo B.Foo B.Foo A.Foo. > >Right. So you see that Ada is different from C++, and your description of >C++ in Ada terms gives the wrong results. You said earlier that: > > That is one of several possible interpretation of what happens > in C++ using Ada terms. > >but the other interpretation you offered doesn't correspond to how C++ >behaves. My interpretation was that if C++ dispatches then it treats the type as class wide,, otherwise as specific. Then the object is always treated as specific in all calls from destructor. So what? Maybe it is hard to simulate, but well possible to explain. >That was my only point, really. > >> Why on earth a call to Foo from B.Finalize should dispatch? The type >> is known, so there is only one version of Foo to be called. > >Let's not muddle the issue with compiler optimisations. A C++ compiler is >allowed to replace dynamic dispatch with static if it can deduce the >dynamic type of the object at compile-time. Which is almost impossible in general case. However it has nothing to do with optimisation. It is the language design issue. >Constructors are not a special >case (although the deduction is unusually simple for them). All of this is >under the "as if" rule. C++ must behave as if it dynamically dispatched in >constructors. Regards, Dmitry Kazakov