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: a07f3367d7,5af5c381381ac5a7 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Ada requires too much typing! Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <03f84a0a-e070-43a9-9b68-920345f64f94@r27g2000yqb.googlegroups.com> <1c704c1e-1b2e-427f-ae0e-3b2a0f976c7c@y4g2000yqy.googlegroups.com> <14cxhfhcbdmaa$.gp6rbqu5865h.dlg@40tude.net> <457b9c75-1c94-4137-a823-2db342cb26d1@c10g2000yqi.googlegroups.com> <1bghlzj6b2s34.19id3bthuckg5$.dlg@40tude.net> Date: Thu, 10 Jun 2010 10:15:14 +0200 Message-ID: <14jtohooi5uxn.rc9dqd69iwnk.dlg@40tude.net> NNTP-Posting-Date: 10 Jun 2010 10:15:15 CEST NNTP-Posting-Host: de53e274.newsspool4.arcor-online.net X-Trace: DXC=]1ne^9n[YVe016@cHD@m;j4IUK;CmPjE@Gi X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:12532 Date: 2010-06-10T10:15:15+02:00 List-Id: On Wed, 9 Jun 2010 14:22:53 -0700 (PDT), Maciej Sobczak wrote: > On 9 Cze, 16:29, "Dmitry A. Kazakov" > wrote: > >>> What is the common base class/interface for C++ or Ada containers? >> >> generic >> � �type Element is private; >> package Generic_Stack is >> � �type Stack is limited private; >> � �... >> end Generic_Stack; >> >> The common base is the [generic] interface of Stack, which all instances >> share, which every programmer has in mind talking about stack. > > Do you mean that every container supports push and pop operations > (actually Append, Last_Element, Delete_Last, etc.)? Yes. >>> How can I use it? >> >> You cannot, which is the problem of generics. > > Or maybe not generics in general, but the specific approach to > generics that was chosen by Ada. > Remember, in C++ this is not a problem: > > #include > #include > > template > void appendThreeInts(ContainerOfInts & c) > { > c.push_back(7); > c.push_back(42); > c.push_back(123); > } > > int main() > { > std::vector vec; > std::list lst; > > appendThreeInts(vec); > appendThreeInts(lst); > } > > The appendThreeInts function uses the implicit common interface, even > though vector and list do not share anything explicitly. You didn't use it. Nowhere in the program it was manifested. It appears that the program "uses" this common interface. But this "use" is as virtual as one by the hex code produced by the compiler. Similarly you could take an int variable, put there 4 and claim that the variable is even, "per use". But it is not. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de