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!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!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> Date: Wed, 14 Sep 2005 09:49:13 +0200 Message-ID: <1idpvzxcxfckw.mrs8nw3eu4ks$.dlg@40tude.net> NNTP-Posting-Date: 14 Sep 2005 09:49:06 MEST NNTP-Posting-Host: 47faa0c7.newsread2.arcor-online.net X-Trace: DXC=n?D9BSA]\6DQ8mU0GR8]WRXZ37ga[7Zn919Q4_`VjYB8=X\UUgbkT X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:4646 Date: 2005-09-14T09:49:06+02:00 List-Id: On Tue, 13 Sep 2005 21:29:06 +0200, Ludovic Brenta wrote: > Martin Krischik writes: >> That's because all class members are virtual in Ada. > > I think this needs to be elaborated on. > > All _primitive operations of a tagged type_ are _potentially_ > "virtual" in Ada. Each caller of such a primitive operation decides, > at the call site, whether the dispatching is static or dynamic. Ada's model is quite simple and logical. If T appears as a formal parameter or the result of a primitive operation of T, then this parameter is controlled (= the operation can dispatch on it.) Dispatching is determined not by any site but exclusively by the actual parameter type. It must be of T'Class. For this reason re-dispatching never happens. To re-dispatch, one should explicitly convert T to T'Class. > In contrast, in (my recollection of) C++, all virtual methods dispatch > dynamically from all call sites: the decision is not made at the point > of call but at the point of definition of the method. C++ model is more tricky and in some aspects more limited. Only the prefix (distinguished) parameter can be controlled (the "this-parameter".) The result cannot be controlled as well. There is no difference between T and T'Class (the source of countless problems.) So all operations re-dispatch except for constructors and destructors, which don't. I.e. it is rather C++ where the call site determines whether a virtual function dispatches. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de