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,5af5c381381ac5a7 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!usenet-fr.net!gegeweb.org!aioe.org!not-for-mail From: =?iso-8859-15?Q?Yannick_Duch=EAne_=28Hibou57=29?= Newsgroups: comp.lang.ada Subject: Re: Ada requires too much typing! Date: Thu, 10 Jun 2010 01:09:55 +0200 Organization: Ada At Home 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: gb35rL9EZW5EtzrYN+nHvA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes Content-Transfer-Encoding: Quoted-Printable X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 User-Agent: Opera Mail/10.53 (Win32) Xref: g2news1.google.com comp.lang.ada:11542 Date: 2010-06-10T01:09:55+02:00 List-Id: Le Wed, 09 Jun 2010 23:22:53 +0200, Maciej Sobczak = a =E9crit: > 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 Although it would requires a different layout (actually, just more typin= g = ;) ), the same is possible with Ada : just use a formal subrpogram = parameter for pubsh_back. You would better use the notation: with My_Subprogram (...signature...) is <>; or even (left oftenly, while still valid and meaningful) with My_Subprogram (...signature...) is null; to get benefit from static polymorphism. About this kind of generic formal parameter, please, see [ARM 2005 12.16= = (2.1/2)] and [ARM 2005 12.16 (10)] and [ARM 2005 12.16 (10.1/2)]. Static polymorphism is achieved when you use a consistent naming shame f= or = similar subprograms in different areas or packages : ex. you define a = Lists package with a Push procedure and a Stacks package with a Push = procedure also (same name in both package). All of these, providing I have really understood what you were requestin= g = for. -- = There is even better than a pragma Assert: a SPARK --# check. --# check C and WhoKnowWhat and YouKnowWho; --# assert Ada; -- i.e. forget about previous premises which leads to conclusion -- and start with new conclusion as premise.