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!news3.google.com!feeder3.cambriumusenet.nl!feeder1.cambriumusenet.nl!feed.tweaknews.nl!193.201.147.85.MISMATCH!border-2.ams.xsnews.nl!feed.xsnews.nl!border-1.ams.xsnews.nl!border1.nntp.ams.giganews.com!nntp.giganews.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 11:45:28 +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: Nb3RqOteARkaxo3NYe5QDQ.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:16552 Date: 2010-11-18T11:45:28+01:00 List-Id: Le Thu, 18 Nov 2010 11:47:03 +0100, a = =C3=A9crit: > On Thu, 18 Nov 2010, Yannick Duch=C3=AAne (Hibou57) wrote: > >> 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). > > Why is that a big deal? The instance of a polymorphic data structure m= ust > somehow be told which operations to use, anyway. Yes, except that it should be in the implementation. One of the matter with the use of generic in that purpose, is that you = must re-create another package specification for the implementation = package. You have the abstract interface, you have an implementation = package, which come with an interface and a body, and you must bind this= = with another package, which is to be an instantiation of the first one = with parameters provided by the second one. With SML (as I did a = comparison with that language), you have an interface, ex. signature MY_INTERFACE =3D sig ... (* some specifications *) end then an implementation among multiple others (if you wish, and typically= , = there will be multiple): structure My_Interface_Implementation_1 :> MY_INTERFACE =3D struct ... (* implementation *) end ( the =E2=80=9C:>=E2=80=9D is for opaque instance, you may use =E2=80=9C= :=E2=80=9D for non-opaque) No more, because it does not need more. The abstract interface behave like a type definition, and you declare an= = implementation instance, just like an entity instance. You can have = multiple instance simultaneously, so that if you want This implementatio= n = of a container for This purpose, and That implementation of the same = container for That usage, you can. Yes, this is feasible with generics (the closest thing available with = Ada), or with static polymorphism (as do the ARM and as Jean-Pierre = suggested). At least, the generic way do some checks and ensure = consistency; the static polymorphism way does not at all (so I would = recommend generics). What I feel is not clean with the generic way, is t= he = need to create an un-useful second interface (un-useful duplication) for= = each implementation, a framework body for the generic (non-sense here), = = and the need for an explicit instantiation (this instantiation is a seco= nd = un-useful copy of stuffs). All of this forms noise and weight the design= , = disturb the comprehension and does not express what it should express (t= oo = many steps for such a simple things does not help to understand what is = = important). I am sure Ada could support this, as it already have all of what is need= ed = for that (separation of implementation and interface, just not separated= = enough). We may declare an interface like for any generic package; this generic = would *not have any body*. We may declare the existence of an = implementation instance in a terse way with something as short as a = renaming package or package instantiation; this one would come *with a = body* (which would be checked against the specification of the abstract = = interface) and the client side would reference this package which would = = implicitly import the interface of the first one (the abstract one). Thi= s = would only use things which are already there with Ada, just the way to = = bind these together would need to be updated. This could be done in a wa= y = which could preserve compatibility, as this would touch nothing else. -- = 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]