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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,56131a5c3acc678e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-12-09 07:05:12 PST Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!news-out.visi.com!petbe.visi.com!newspeer.monmouth.com!newspeer1.nwr.nac.net!nntp.cifnet.net!nntp-relay.ihug.net!ihug.co.nz!hkg.uu.net!osa.uu.net!sac.uu.net!ash.uu.net!spool.news.uu.net!not-for-mail Date: Tue, 09 Dec 2003 10:05:07 -0500 From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5) Gecko/20031013 Thunderbird/0.3 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Question about OO programming in Ada References: <1273941.m4G3ZzughP@linux1.krischik.com> <1070889942.156714@master.nyc.kbcfp.com> <5lcBb.4138$UM4.2773@nwrdny01.gnilink.net> <1070976556.767919@master.nyc.kbcfp.com> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Organization: KBC Financial Products Message-ID: <1070982307.973327@master.nyc.kbcfp.com> Cache-Post-Path: master.nyc.kbcfp.com!unknown@aphelion.nyc.kbcfp.com X-Cache: nntpcache 3.0.1 (see http://www.nntpcache.org/) NNTP-Posting-Host: 204.253.250.10 X-Trace: 1070982308 1442 204.253.250.10 Xref: archiver1.google.com comp.lang.ada:3274 Date: 2003-12-09T10:05:07-05:00 List-Id: Dmitry A. Kazakov wrote: > Again, implementation issue is irrelevant. It is a subroutine that is > dispatching [in a parameter]. The object is not. The difference > becomes especially clear, when you consider multiple dispatch. But the common OO languages don't support multiple dispatch, and whether or not you regard implementation as irrelevant, it is nevertheless the case that dispatching in those languages is coordinated around the object type, not separately around each dispatching function. > This is exaclty what I meant by claiming that it is not a class-wide > pointer. A dispatching subroutine is defined on the whole class > (=closure of the domains of all derived types). Each override > represents a part of its body called according to the type tag. The > behaviour in C++ constructors/destructors clearly violates this. So > either the type is not class-wide or the subroutine is not > dispatching. Choose what you want, the result is same. You either-or is a false dichotomy. As you say, "Each override represents a part of its body called according to the type tag." In C++, the type tag stored within the object changes as the code progresses through constructors and destructors. Didn't I post this sample code already? #include struct A { virtual void f() { printf("A"); } void g() { f(); } // This call is always dispatching A() { g(); } } struct B : A { void f() { printf("B"); } // overrides A::f B() { g(); } } int main() { B b; b.g(); } This code prints "ABB". In A::g, the type of 'this' is 'pointer-to-A'. The dynamic type of '*this' is A when called from A's constructor and B when called from B's constructor, because the compiler is updating the tag within the object as its construction progresses. The call to f in A::g always dispatches using the dynamic type of '*this'.