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,8e7ac81a215f128c X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,UTF8 Path: g2news2.google.com!news4.google.com!feeder.news-service.com!94.75.214.39.MISMATCH!aioe.org!not-for-mail From: =?utf-8?Q?Yannick_Duch=C3=AAne_=28Hibou57?= =?utf-8?Q?=29?= Newsgroups: comp.lang.ada Subject: Re: Using Red-Black Trees Date: Thu, 18 Nov 2010 08:08:00 +0100 Organization: Ada @ Home Message-ID: References: <2419e829-6f45-4075-9005-b9876beb8aaa@r6g2000vbf.googlegroups.com> <46306fd9-21dc-40df-88e7-fc7e568399a4@k11g2000vbf.googlegroups.com> NNTP-Posting-Host: EFpv4lnpRyjbMhM0po550g.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; 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.63 (Win32) Xref: g2news2.google.com comp.lang.ada:16542 Date: 2010-11-18T08:08:00+01:00 List-Id: Le Thu, 18 Nov 2010 07:27:20 +0100, J-P. Rosen a =C3=A9= crit: > Le 18/11/2010 00:39, Yannick Duch=C3=AAne (Hibou57) a =C3=A9crit : >> You can have only one at a time. If you select an implementation, you= >> select it system-wide, and you cannot select one for that usage and >> another for another usage in the same system. >> > If that's really what you want, there is an easy solution. > Provide two packages with identical (or compatible enough for your > purpose) specifications: > > package Binary_Tree is.... > package Linked_List is.... > > Then declare at library level: > with Binary_Tree; > package My_Structure renames Binary_Tree; > > And then, use My_Structure all over the place. By changing two words i= n > one two-line file, you can switch your entire project to the other > implementation. I know that one, but this is a workaround, not a language support (the s= o = called =E2=80=9Cstatic polymorphism=E2=80=9D). Formally speaking, you do= not have multiple = implementations of a single specification. The closest thing actually is= = generic package. But that is not easy to do with generics: you will have= = to give the generic instance all of its custom implementation via generi= c = parameters (methods and others). -- = Si les chats miaulent et font autant de vocalises bizarres, c=E2=80=99es= t pas pour = les chiens. =E2=80=9CI am fluent in ASCII=E2=80=9D [Warren 2010]