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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5af5c381381ac5a7 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!k39g2000yqb.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: Ada requires too much typing! Date: Wed, 9 Jun 2010 14:22:53 -0700 (PDT) Organization: http://groups.google.com Message-ID: 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> NNTP-Posting-Host: 83.77.132.25 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1276118573 23786 127.0.0.1 (9 Jun 2010 21:22:53 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 9 Jun 2010 21:22:53 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: k39g2000yqb.googlegroups.com; posting-host=83.77.132.25; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3,gzip(gfe) Xref: g2news1.google.com comp.lang.ada:11540 Date: 2010-06-09T14:22:53-07:00 List-Id: On 9 Cze, 16:29, "Dmitry A. Kazakov" wrote: > > What is the common base class/interface for C++ or Ada containers? > > generic > =A0 =A0type Element is private; > package Generic_Stack is > =A0 =A0type Stack is limited private; > =A0 =A0... > 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.)? > > 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. -- Maciej Sobczak * http://www.inspirel.com YAMI4 - Messaging Solution for Distributed Systems http://www.inspirel.com/yami4