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: 103376,8e7ac81a215f128c X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Using Red-Black Trees 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: <2419e829-6f45-4075-9005-b9876beb8aaa@r6g2000vbf.googlegroups.com> <46306fd9-21dc-40df-88e7-fc7e568399a4@k11g2000vbf.googlegroups.com> Date: Thu, 18 Nov 2010 10:02:56 +0100 Message-ID: <1g4kzlu0ma9k7$.1t1gq0uvi1a5y.dlg@40tude.net> NNTP-Posting-Date: 18 Nov 2010 10:02:56 CET NNTP-Posting-Host: 14de3e61.newsspool2.arcor-online.net X-Trace: DXC=ldI4;Q1dlX>n`gW2MTm]<3A9EHlD;3Yc24Fo<]lROoR18kF7enW;^6ZC`4\`mfM[68DC3IP74n6n2\85 X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:15576 Date: 2010-11-18T10:02:56+01:00 List-Id: On Thu, 18 Nov 2010 07:27:20 +0100, J-P. Rosen wrote: > Le 18/11/2010 00:39, Yannick Duch�ne (Hibou57) a �crit : >> 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; Yes of course it is a simple, but non-Ada solution. BTW, I am using it for years, with a small addition that the implementation is selected by the gpr-file. But it is not Ada it is pure C, because nothing is checked. An Ada way would be abstract packages, i.e. a package that describes the public part of some other package. The program could be developed in terms of the abstract package(s) required to be substituted by an implementation package. Upon substitution the actual package specification would be checked. This is close to a formal generic packages but "typed." In effect you have a package type and packages are values of. Something of this sort could be done in existing Ada, but in a quite ugly way: generic type T is private; -- The formal parameters play role with procedure F; -- of a "specification" of Abstract_P type package Abstract_P is -- Nothing here end Abstract_P; generic with package Concrete_P is new Abstract_P; package My_Stuff is ... -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de