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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,342dcd67e9ca73ee X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!z14g2000cwz.googlegroups.com!not-for-mail From: "Hyman Rosen" Newsgroups: comp.lang.ada Subject: Re: tagged record child: override constructor? Date: 14 Sep 2005 06:52:55 -0700 Organization: http://groups.google.com Message-ID: <1126705974.984997.227590@z14g2000cwz.googlegroups.com> References: <1126591134.797303.318920@z14g2000cwz.googlegroups.com> <1uri5gd2n7om0.1ujkzb26ayxdx.dlg@40tude.net> <1126625009.709876.226260@f14g2000cwb.googlegroups.com> <225337460.SlYKbeB8eD@linux1.krischik.com> <87vf14him5.fsf@ludovic-brenta.org> <1idpvzxcxfckw.mrs8nw3eu4ks$.dlg@40tude.net> <13wyu4lwsmzmz.ktc3t2av54yv$.dlg@40tude.net> NNTP-Posting-Host: 204.253.248.208 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1126705980 20841 127.0.0.1 (14 Sep 2005 13:53:00 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 14 Sep 2005 13:53:00 +0000 (UTC) User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.10) Gecko/20050716 (No IDN) Firefox/1.0.6,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: z14g2000cwz.googlegroups.com; posting-host=204.253.248.208; posting-account=lJDDWg0AAACmMd7wLM4osx8JUCDw_C_j Xref: g2news1.google.com comp.lang.ada:4659 Date: 2005-09-14T06:52:55-07:00 List-Id: Dmitry A. Kazakov wrote: > 1. It is space inefficient. To have T and T'Class same requires keeping the > type tag in all Ts, while it is only necessary in T'Class. No Ada implementation takes this approach, though. They all keep a type tag in every tagged object. > 3. It is inefficient, because it has to dispatch everywhere In C++, however, you have already declared some functions to be dispatching (virtual) and some not. For those functions which are virtual, dispatching is what's wanted. How many Ada newbies get completely confused trying to figure out what dispatches and what doesn't? Do any of them write T'Class the first time? > 4. It is error-prone because of enforced re-dispatch It is error-prone not to dispatch, because the first thing everyone learns about OO is that methods dispatch! It's only after significant hair-pulling that an Ada newbie will realize why his overriden methods are not being called. > 5. When T and T'Class are same, objects have identity. Huh? All type tags for a given type are identical. Why does embedding a type tag in an object give it any more identity than not doing so? > The implementation of Foo stay consistent no matter what a derived type > would do with Bar. Except that when the programmer overrides Bar for derived types, he's going to be monumentally confused as to why Foo isn't calling it. Foo is going to be consistent, but as far as the programmer is concerned, it's going to be consistently incorrect. > Re-dispatch usually indicates a design problem. What nonsense! > Yes, they do as if they wouldn't. To me it is that they don't. As has been repeatedly demonstrated to you, this is just wrong. Once again, here is the code: struct A { virtual void f() { print("A"); } void g() { f(); } A() { g(); } ~A() { g(); } }; struct B : A { void f() { print("B"); } B() { g(); } ~B() { g(); } }; int main() { B b; } This will print "ABBA", demonstrating that dispatching is occuring within g() even when it is called from a constructor or destructor.