comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov>
Subject: Re: Ada 0y wish list: parameters of package parameters
Date: 20 Feb 2001 13:28:31 -0500
Date: 2001-02-20T18:42:08+00:00	[thread overview]
Message-ID: <uvgq5dx9s.fsf@gsfc.nasa.gov> (raw)
In-Reply-To: 3A8E3533.948C6618@linuxchip.demon.co.uk

Dr Adrian Wrigley <amtw@linuxchip.demon.co.uk> writes:

> <snip>
> 
> 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



  reply	other threads:[~2001-02-20 18:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-02-15 13:07 Ada 0y wish list: parameters of package parameters Michel Gauthier
2001-02-17  8:24 ` Dr Adrian Wrigley
2001-02-20 18:28   ` Stephen Leake [this message]
2001-02-20 18:37 ` Ehud Lamm
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox