comp.lang.ada
 help / color / mirror / Atom feed
From: Brian Rogoff <bpr@shellx.best.com>
Subject: Generic formal package parameter question
Date: 1997/08/21
Date: 1997-08-21T00:00:00+00:00	[thread overview]
Message-ID: <Pine.SGI.3.95.970821223052.24A-100000@shellx.best.com> (raw)


	There are two forms for generic formal package parameters

with package P is new G(<>);

or

with package P is new G( Q1, Q2, ..., QN );

Why there isn't an intermediate form where some, but not necessarily 
all, of the parameters appear in the parameter list, allowing us to 
better represent the relationships between the parameters? 

For example, suppose we have two generic signature packages, Assignable 
and Composable

generic
    type Assignable_Type is limited private;
    with procedure Assign( From : in out Assignable_Type;
                           To : out Assignable_Type );
package Assignable is end;

generic
    type Comparable_Type is limited private;
    with function Compare ( X, Y : Comparable_Type ) 
        return Comparison_Type; -- Boolean or three-valued
package Comparable is end;

and we want a third package to have a generic formal parameter which is 
both Assignable and Comparable. I'd like to be able to express it like 
this

generic 
    type Value_Type is private;
    with package Comparable_Values is 
        new Comparable( Value_Type, <> );  -- Illegal
    with package Assignable_Values is 
        new Assignable( Value_Type, <> );  -- Illegal
package Assignable_Comparable is end;

but Ada forces an all or nothing approach here, and I have to choose
nothing (<>) rather than be able to express those constraints that I can,
in this case  that both of the signature packages are instantiated with
Value_Type. This seems really against the spirit of Ada to me, so I'm
curious as to the reasons for this limitation. 

-- Brian






             reply	other threads:[~1997-08-21  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-08-21  0:00 Brian Rogoff [this message]
1997-08-22  0:00 ` Generic formal package parameter question Tucker Taft
1997-08-22  0:00   ` Brian Rogoff
replies disabled

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