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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham 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!news2.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Alex R. Mosteo" Newsgroups: comp.lang.ada Subject: Re: tagged record child: override constructor? Date: Wed, 14 Sep 2005 11:28:40 +0200 Message-ID: <4327ED48.5000603@mailinator.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> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net HX8XQDvl9WdFVjLn6v6/3Q4sqSKdYlaGFfIeTpwx15zD4g8S4= User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050716) X-Accept-Language: en-us, en In-Reply-To: <87vf14him5.fsf@ludovic-brenta.org> Xref: g2news1.google.com comp.lang.ada:4652 Date: 2005-09-14T11:28:40+02:00 List-Id: 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. > > 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. This is worth stressing. I was bitten by this distinction in cases like this: type Blah is tagged ...; procedure Do_Something (B : Blah); -- Default processing, -- To be overriden/extended by descendant types. procedure Run (B : Blah) is begin ... Do_Something (B); end Run; If you make a descendant type (say Duh), the call inside Duh.Run will not be dispatching, but will call the Blah.Do_Something. This is plain vanilla consequence of what you say, but for newcomers to Ada could be an easy mistake to made. -- Take the Snape polls: http://snape.mosteo.com [Updated 16/05]