From: akonstan@news.cs.columbia.edu (Alexander V. Konstantinou)
Subject: Formal Packages definition limitation
Date: 1996/09/13
Date: 1996-09-13T00:00:00+00:00 [thread overview]
Message-ID: <51cofa$ku4@herald.cs.columbia.edu> (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
reply other threads:[~1996-09-13 0:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox