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!g44g2000cwa.googlegroups.com!not-for-mail From: "Hyman Rosen" Newsgroups: comp.lang.ada Subject: Re: tagged record child: override constructor? Date: 15 Sep 2005 06:19:40 -0700 Organization: http://groups.google.com Message-ID: <1126790380.573573.78220@g44g2000cwa.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> <1126705974.984997.227590@z14g2000cwz.googlegroups.com> <1126718176.448703.193860@g44g2000cwa.googlegroups.com> <1aroipmwspnb8.zqxtxhb4t06u$.dlg@40tude.net> <1126731371.081850.90860@g44g2000cwa.googlegroups.com> <12v93t1k4i81i$.sm5jmg8q3lpk$.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 1126790385 348 127.0.0.1 (15 Sep 2005 13:19:45 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 15 Sep 2005 13:19:45 +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: g44g2000cwa.googlegroups.com; posting-host=204.253.248.208; posting-account=lJDDWg0AAACmMd7wLM4osx8JUCDw_C_j Xref: g2news1.google.com comp.lang.ada:4709 Date: 2005-09-15T06:19:40-07:00 List-Id: Dmitry A. Kazakov wrote: > Which mistake? Again, it is solely the actual object's *type* which > determines dispatch. The mistake of not calling the overridden method of the actual type of the object rather than of the declared type. In OO programming, by-reference objects have two types, their declared base type and their actual created type. In OO programming, it is expected by the programmers that a call to a potentially overridden function using a base by-reference object will dispatch to the overridden function. If the language claims to support OO but then makes it easy to call these methods in such a way that overriding doesn't happen, and without warning, then the language has introduced a dangerous trap. That is supposedly antithetical to the spirit of Ada. > It is 100% safe, intuitive and unambiguous. It is not intuitive at all, except to people whose intuition has been warped. It's just plain wrong. > Ada is a typed language! Is C++ one? It's the Ada language that has caused itself this problem. C++ requires that you clearly distinguish between a reference to an object, a pointer to an object, and the object itself. Thus, when you see a pointer or reference to a base class, you know that the referee object may be of a derived class, and that dispatching may take place. Ada, in trying to be clever about hiding parameter passing mode from the programmer, and by not supporting a distinguished dispatching object syntax, let itself in for a trap. > No. It calls B::g() which was inherited from A. I don't care if code of > B::g() and A::g() share memory or not. They are different functions because > their signatures are different. No, they are the same function. If, for example, I included a static variable within it, calls to A::g() and B::g() would see the same variable. And for that matter, simply write this: #include #include struct A { void g(); }; struct B : A { }; int main() { std::cout << (&A::g == &B::g) << "\n"; } and you'll see whether the compiler thinks they're the same or not. > It does not. It calls B::f() from B::g() No. There is no B::g separate from A::g. Inherited functions are not copies, they are the same function. There is no code you can write which will demonstrate a difference.