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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC 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!news3.google.com!news.glorb.com!easynet-monga!easynet.net!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: tagged record child: override constructor? Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH 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> Date: Wed, 14 Sep 2005 22:20:41 +0200 Message-ID: <1aroipmwspnb8.zqxtxhb4t06u$.dlg@40tude.net> NNTP-Posting-Date: 14 Sep 2005 22:19:46 MEST NNTP-Posting-Host: 211d934d.newsread4.arcor-online.net X-Trace: DXC=K]If\oiL7eXTkno\?fPDcV:ejgIfPPldTjW\KbG]kaMXFYk:AnJB[C];?E3AjS4WP[[6LHn;2LCV^VVa[ZlQni_QE4QX\1C=A;U X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:4675 Date: 2005-09-14T22:19:46+02:00 List-Id: On 14 Sep 2005 10:16:16 -0700, Hyman Rosen wrote: > 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. That does not invalidate my point. You need dispatch only if you have a class-wide object. So if your newbie doesn't write T'Class s/he doesn't need it. > Without it, you just have ADTs. Which is all I need! There is no magic in OO. Class is just an ADT. Polymorphic object is just a value of that ADT. A polymorphic operation is just an operation defined on that ADT, which body is composed out of parts defined by specific types. >> 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? It was your point that for a newbie coming from C++ it might appear difficult to understand Ada. But as it was pointed out many times before, Ada's default choices are the safest ones. Thus by default an operation on a tagged type is primitive and dispatching. C++ choices are at most adventurous. The languages designers had different goals in mind. So for a newbie it indeed might look as a paradigm shift. High time it is. >> 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. That is how *class-wide* types work. Class-wide objects have the type identity. Specific types need not, because in Ada you cannot dispatch on them. >> 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. There is no point in adopting what other languages did wrong. > The only difference is what type tag > the object contains when the dispatching happens. As I said before, it is equivalent to dispatch that does not happen. How the compiler implements it, by either patching the dispatch table or not, I don't care. It is a *consistent* behavior, and it is how Ada does it everywhere. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de