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 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED.3d73Ybk3C5U4I2t8lv+lAQ.user.gioia.aioe.org!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Using Generic Pasckages Date: Thu, 9 Apr 2020 10:57:12 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <5e8edf69$0$18432$e4fe514c@news.kpn.nl> NNTP-Posting-Host: 3d73Ybk3C5U4I2t8lv+lAQ.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 X-Notice: Filtered by postfilter v. 0.9.2 Content-Language: en-US Xref: reader01.eternal-september.org comp.lang.ada:58332 Date: 2020-04-09T10:57:12+02:00 List-Id: On 2020-04-09 10:40, ldries46 wrote: > I have created some generic packages. tese are packages that only do the > same thing but with other types. Till now I did only need these packages > without interaction with between packages using the same type. I just > can declare them: > Package AA is new BB(type); then calling them as > A := AA.Get_Value; > No other declaration seemed to be neccesary . > > Now I have the following situation: > Package AA is new BB(integer); > Package CC is new BB(integer); > and a case where I have several statements using Package AA in one > condition and CC the other case. > I want  to do that by using: > if D then EE := AA; else EE := CC; end if; > But I cannot find in the documentation  how the declaration of EE should > be made. > > Of course there is the possibility to create the same progrram without > using EE but that is far less readable and thus creating more possible > errors. > > If I have to do this without the generic packages I already have the > program alse will be less readable. What you are observing is the advantages of dynamic polymorphism (tagged types) over the static one (generics). Already the name static hints that you cannot select a polymorphic implementation (AA or CC) using some non-static (dynamic) expression D. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de