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,LOTS_OF_MONEY autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,599b13f801b0f9eb X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-07-25 09:10:12 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!east1.newsfeed.sprint-canada.net!news.storm.ca!nnrp1.tor.metronet.ca!not-for-mail Message-ID: <3B5EEF62.6BA4104B@home.com> From: "Warren W. Gay VE3WWG" X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: C++ virtual function mechanism in Ada ? References: <9jmif2$et3$1@s1.read.news.oleane.net> Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Date: Wed, 25 Jul 2001 16:10:11 GMT NNTP-Posting-Host: 198.96.47.195 NNTP-Posting-Date: Wed, 25 Jul 2001 10:10:11 MDT Organization: MetroNet Communications Group Inc. Xref: archiver1.google.com comp.lang.ada:10564 Date: 2001-07-25T16:10:11+00:00 List-Id: Jean-Pierre Rosen wrote: > > "Didier.pieroux" a �crit dans le message news: IDz77.6315$ar1.18443@www.newsranger.com... > [snipped for brievity] > > > One way to get the job done is to use: > > procedure F(A: in T1) is begin Put("F1:"); E(T1'Class(A)); end F; > > That switches the dynamical dispatching on and everybody is happy. But the bad > > point is that I have the impression that extending a base type can require > > modifications in that base type implementation. Too bad for code reliability, > > isn't it ? > This is the right way to do it. > > > > > So, my first question is: knowing that a characteristic feature of primitive > > operations is to call them with objects of a derived type, why did the Ada > > designers choose not to use dynamical dispatching when calling a primitive > > function ? I guess that most of the time Ada programmers (as C++ programmers) > > want to really call the primitive operation corresponding to the type of the > > actual parameter, no ? > A fundamental question, so let's go. > There is a fundamental difference between C++ and Ada: in C++, dispatching is a property of the function (virtual or not). > Second: Ada is a language driven by types. It is always the *type* of the parameters that determines what is called. Don't forget that in Ada95, the return value type can also be important ;-) C++ does not dispatch on the return type. -- Warren W. Gay VE3WWG http://members.home.net/ve3wwg