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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5b080dc7a4a5ad15 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-02-20 10:37:35 PST Path: supernews.google.com!sn-xit-02!sn-xit-04!supernews.com!feed.textport.net!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Ada 0y wish list: parameters of package parameters Date: 20 Feb 2001 13:28:31 -0500 Organization: NASA Goddard Space Flight Center Message-ID: References: <3A8E3533.948C6618@linuxchip.demon.co.uk> NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 982694528 10807 128.183.220.71 (20 Feb 2001 18:42:08 GMT) X-Complaints-To: dscoggin@cne-odin.gsfc.nasa.gov NNTP-Posting-Date: 20 Feb 2001 18:42:08 GMT User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.6 Xref: supernews.google.com comp.lang.ada:5375 Date: 2001-02-20T18:42:08+00:00 List-Id: Dr Adrian Wrigley writes: > > > My solution was to add generic functions, which converted > between the types: > > with package Structure_1 is new Algrbraic_Structure ( <> ) ; > with package Structure_2 is new Order_Structure ( <> ) ; > with function Convert (X : Structure_1 . Item_Type) > return Structure_2.Item_Type; > with function Convert (X : Structure_2 . Item_Type) > return Structure_1.Item_Type; > > This allows the package to use the two types interchangably, > provided that the Convert functions are called, if necessary. > You could use Unchecked_Conversion between the types, if you > believe them to be the same. Better to use an inlined Copy function; the compiler will warn you if something changes during maintenance. > The alternative I could see in my case was to replace the package > generic parameters with all the contents of the specification that > were needed. Every time a type occurs which need to be the same in > Structure_1 and Structure_2, you only have it once. This is general > (I think), but can be very verbose, and obscures the abstraction. Perhaps Item_Type should be a generic parameter of both Structure_1 and Structure_2? -- -- Stephe