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 05:29:17 PST Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!zeus.visi.com!news-out.visi.com!petbe.visi.com!uunet!ash.uu.net!spool.news.uu.net!not-for-mail Date: Tue, 09 Dec 2003 08:29:16 -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> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Organization: KBC Financial Products Message-ID: <1070976556.767919@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: 1070976556 24495 204.253.250.10 Xref: archiver1.google.com comp.lang.ada:3271 Date: 2003-12-09T08:29:16-05:00 List-Id: Dmitry A. Kazakov wrote: > Dispatch table is a property of a dispatching subroutine. No it's not, at least not in the nearly universal C++ implementation. In that approach, there exists one dispatch table per tagged class with slots for each virtual function of that class. Then every object of that class contains a pointer to this single dispatch table. To make a dispatching call, the compiler accesses the dispatch table using the index corresponding to the function being called, and calls the method found there. (The model is more complicated due to virtual and multiple inheritance, so that an object may contain pointers to more than one dispatch table, and the addresses are sometimes to fixup thunks, but that doesn't matter here.) I'm pretty sure that at least GNAT implements Ada dispatching the same way. > It is a complementary view. Either we say that the type of an object > is mutating or that the type of a formal parameter does (= changing > the dispatch table = changing the subroutine parameter profile). The > effect is same. It is no more strongly typed. In C++, the type of 'this' in a method is always 'pointer-to-class-type- of-this-method', or a const variant of that. The (dynamic) type of the object pointed to by 'this' can change as control passes through *tors. Note that for typical C++ implementations we are not just "saying" that the type of the object changes; the generated code actually modifies the dispatch table pointer stored within the object as it progresses through its construction and destruction. (In fact, I believe Microsoft's C++ compiler offers an option to disable this for efficiency when you can assure it that it won't matter.)