comp.lang.ada
 help / color / mirror / Atom feed
* Formal Packages definition limitation
@ 1996-09-13  0:00 Alexander V. Konstantinou
  0 siblings, 0 replies; only message in thread
From: Alexander V. Konstantinou @ 1996-09-13  0:00 UTC (permalink / raw)



Consider a generic procedure Iter_Swap (swaps iterators)

generic
  with package Iterators1 is new Forward_Iterators(<>);
  with package Iterators2 is new Forward_Iterators(<>);
procedure Iter_Swap(A: Iterators1.Iterator; B: Iterators2.Iterator);

Now, this definition is too general since I would like to restrict
that 
	Iterators1.Value_Type = Iterators2.Value_Type

A reasonable way to do this (you can argue about the syntax) would be :

generic
  with package Iterators1 is new Forward_Iterators(<>);
  with package Iterators2 is new Forward_Iterators
    (Value_Type=>Iterators1.Value_Type);
procedure Iter_Swap(A: Iterators1.Iterator; B: Iterators2.Iterator);

I'd want the compiler to accept any instantiation of Forward_Iterators
with the limitation that its value type should be Iterators1.Value_Type.

Alas the reference manual defines (Sec. 12.7):

    formal_package_actual_part ::= (<>) | [generic_actual_part]

leaving no room for partial generic_actual_parts.  Any ideas why this
was not allowed ?  At present I am forced to pass two conversion
functions, but that is clearly not a good solution.

Alexander V. Konstantinou
akonstan@cs.columbia.edu
-- 
--
Alexander V. Konstantinou              http://www.cs.columbia.edu/~akonstan/
akonstan@cs.columbia.edu               akonstan@acm.org




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1996-09-13  0:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-09-13  0:00 Formal Packages definition limitation Alexander V. Konstantinou

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