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: 14 Sep 2005 10:16:16 -0700 Organization: http://groups.google.com Message-ID: <1126718176.448703.193860@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> NNTP-Posting-Host: 204.253.248.208 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1126718182 5012 127.0.0.1 (14 Sep 2005 17:16:22 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 14 Sep 2005 17:16:22 +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:4671 Date: 2005-09-14T10:16:16-07:00 List-Id: Dmitry A. Kazakov wrote: > meaningful dispatch is rare. How often the specific type is really unknown? This is just baffling. The whole point of object-oriented programming is that you have classes which conform to an interface but have differing implementations, and those implementations are dispatched to by making a call using a classwide type. That's the whole reason tagged types were implemented in Ada 95. Without it, you just have ADTs. > A goal of Ada design was safe software construction. Putting former C++ > programmers on the right track wasn't. (:-)) How nice for Ada. But what does dispatching have to do with safety? > Because having the tag you can determine the object's type, which might > differ from what the contract states. Ada is based on contract model. That's how tagged types work. That's the whole point of tagged types. You're supposed to be able to get at aspects of the object's real type, via dispatching. > Because it is the contract to determine what's going on. You've got a tagged type, so it's methods should dispatch. That's why you use a tagged type in the first place. When the method call doesn't dispatch that's surprising and unexpected. OO came to Ada late. Making its behavior weirdly different from other OO languages isn't helpful. > It demonstrates that in the calls made from T::T and T::~T the type of > "this" is T. Yes, that's one thing it demonstrates. > f() in A::g() dispatches only if g() wasn't called [directly or indirectly] > from a constructor or destructor. That's false. B::B() and B::~B() both call A::g() (there is no separate B::g() defined), and that dispatches to B::f(). There is no difference in the dispatch mechanism when f() is called, whether or not that call originates in a constructor. The only difference is what type tag the object contains when the dispatching happens.