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-14 07:06:44 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!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 [LONG] Date: Thu, 14 Feb 2002 15:06:41 GMT Message-ID: <3c6bcb27.4632484@News.CIS.DFN.DE> References: <3c68ceeb.88774578@News.CIS.DFN.DE> NNTP-Posting-Host: tar-alcarin.cbb-automation.de (212.79.194.111) X-Trace: fu-berlin.de 1013699201 148766 212.79.194.111 (16 [77047]) X-Newsreader: Forte Free Agent 1.21/32.243 Xref: archiver1.google.com comp.lang.ada:20004 comp.object:34376 Date: 2002-02-14T15:06:41+00:00 List-Id: On Wed, 13 Feb 2002 19:58 +0000 (GMT Standard Time), brangdon@cix.co.uk (Dave Harris) wrote: >dmitry@elros.cbb-automation.de (Dmitry A. Kazakov) wrote (abridged): >> 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. >> [...] >> When you pass it to some other routine an implicit specific->class >> wide conversion happens, so the routine can dispatch again. > >This doesn't work. If you look at the 3 calls to call_foo() in Hyman >Rosen's example, you'll see it dispatches to 3 different places. Therefore >we cannot view the object has having a constant type with 2 kinds of >dispatching. A specific->class-wide conversion would have it printing >C::foo 2 or 3 times. Your view doesn't match the visible behaviour. > >If you think in terms of a conversion, the different calls to call_foo() >must convert to different types. It's not enough to switch the vtable on >and off, you need different conceptual vtables. Yes. C has a tag, B in C has another and A in B in C has the third. This is why I do not like embedded tags. >Given this, its simpler to think of the conversion as happening as soon as >the constructor is entered, rather than when the constructor calls out. Surely. There is a type conversion, but it is an "in-place" conversion. It changes neither the object C nor its type. It only shifts the reference to C.B. >> An Ada 95 equivalent would be: > >Your example only shows 2 types, so doesn't capture the richness of >behaviour of Hyman's example which has 3. I suspect you have misunderstood >it. That there are three types changes nothing. It works pretty well in Ada 95: type A is ... procedure Foo (Object : A) is begin Put_Line ("A.Foo"); end Foo; procedure Finalize (Object : in out A) is begin Foo (Object); -- No dispatch here, A.Foo is called end Finalize; -------------------- type B is new A ... procedure Foo (Object : B) is begin Put_Line ("B.Foo"); end Foo; procedure Finalize (Object : in out B) is begin Foo (Object); -- No dispatch here, B.Foo is called Finalize (A (Object)); -- C++ adds this automatically end Finalize; --------------------------- type C is new B... procedure Foo (Object : C) is begin Put_Line ("C.Foo"); end Foo; procedure Finalize (Object : in out C) is begin Foo (Object); -- No dispatch here, C.Foo is called Finalize (B (Object)); -- C++ adds this automatically end Finalize; When C is finalized, then C.Foo, B.Foo, A.Foo will be printed. Regards, Dmitry Kazakov