comp.lang.ada
 help / color / mirror / Atom feed
From: Brian Rogoff <bpr@shell5.ba.best.com>
Subject: Re: signatures
Date: 1999/07/29
Date: 1999-07-29T00:00:00+00:00	[thread overview]
Message-ID: <Pine.BSF.4.10.9907292015080.15361-100000@shell5.ba.best.com> (raw)
In-Reply-To: Pine.A41.3.96-heb-2.07.990729214156.212760A-100000@pluto.mscc.huji.ac.il

On Thu, 29 Jul 1999, Ehud Lamm wrote:
> Suppose I want to ensure that a to be written set of routines all
> conform to a given signatre (let's say all sort routines have the
> signature 
> generic
>    type item is private;
>    type list is array(positive range <>) of item; 
> procedure sort (s:in out list);
> )?
> 
> What is the preffered way of doing this?

My preferred way would be

generic 
    type Item_Type is private;
    type List_Type is array(Positive range <>) of Item_Type;
    with procedure Sort(S : in out List_Type) is <>;
package Sort_Signature is end;

then instantiate this with some types and a sort procedure. You can use
this package as a package parameter to an implementation package like the 
following.

generic 
    with My_Sort is new Sort_Signature(<>);
package My_Package is 
... etc

A very nice addition to Ada over Ada-83, these package parameters and
signature packages!

-- Brian





  reply	other threads:[~1999-07-29  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-07-29  0:00 signatures Ehud Lamm
1999-07-29  0:00 ` Brian Rogoff [this message]
1999-08-01  0:00   ` signatures Ehud Lamm
1999-08-01  0:00     ` signatures James S. Rogers
1999-08-01  0:00       ` signatures Brian Rogoff
  -- strict thread matches above, loose matches on Subject: below --
1988-12-07 16:36 signatures Stephe Leake
replies disabled

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