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-16 16:28:57 PST Path: supernews.google.com!sn-xit-02!supernews.com!isdnet!grolier!btnet-peer0!btnet!news5-gui.server.ntli.net!ntli.net!news11-gui.server.ntli.net.POSTED!not-for-mail Message-ID: <3A8E3533.948C6618@linuxchip.demon.co.uk> From: Dr Adrian Wrigley X-Mailer: Mozilla 4.7 [en] (X11; U; Linux 2.2.14-5.0smp i686) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Ada 0y wish list: parameters of package parameters References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Sat, 17 Feb 2001 00:24:19 -0800 NNTP-Posting-Host: 62.253.132.124 X-Complaints-To: abuse@ntlworld.com X-Trace: news11-gui.server.ntli.net 982369422 62.253.132.124 (Sat, 17 Feb 2001 00:23:42 GMT) NNTP-Posting-Date: Sat, 17 Feb 2001 00:23:42 GMT Organization: ntl Cablemodem News Service Xref: supernews.google.com comp.lang.ada:5316 Date: 2001-02-17T00:24:19-08:00 List-Id: Michel Gauthier wrote: stuff deleted... > Ada-95 solutions are complex and not fully general. > A possible syntax could be : > > with package Structure_1 is new Algrbraic_Structure ( <> ) ; > with package Structure_2 is new Order_Structure > ( Structure_1 . Item_Type , others => <> ) ; > > Any suggestion or opinion ? Yes! I had a simlar problem a while back. I was working on numerical integration code, and wanted to bring together three such signature packages. One defined the domain of integration, one defined the type of the result, one defined the integrand function. Of course, the generic should specify that the integrand must return the same type At the time I was new to Ada, and expected to be able to use your syntax above - it seemed the "Ada way". I contacted a (well known) Ada expert, and was advised it couldn't be done how I wanted. 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. 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. I can't at this moment see any major implementation problem with Michel's suggestion, but I'm not qualified to comment. Maybe someone here should sumbit a proposal to address the problem. -- Dr Adrian Wrigley