comp.lang.ada
 help / color / mirror / Atom feed
* Generic formal package parameter question
@ 1997-08-21  0:00 Brian Rogoff
  1997-08-22  0:00 ` Tucker Taft
  0 siblings, 1 reply; 3+ messages in thread
From: Brian Rogoff @ 1997-08-21  0:00 UTC (permalink / 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






^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1997-08-22  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-08-21  0:00 Generic formal package parameter question Brian Rogoff
1997-08-22  0:00 ` Tucker Taft
1997-08-22  0:00   ` Brian Rogoff

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