From: terminator!caen!uvaarpa!software.org!smithd@gumby.wisc.edu (Doug Smith)
Subject: Re: Ada 9X plans for Generic Formal Packages
Date: 13 Apr 92 22:13:07 GMT [thread overview]
Message-ID: <1992Apr13.221307.2127@software.org> (raw)
In article <1992Apr8.154108.2294@wdl.loral.com> mab@wdl39.wdl.loral.com (Mark A
Biggar) writes:
> In article <1992Apr7.192922.24708@software.org> smithd@software.org (Doug Smi
th) writes:
> >A quick look at the March 92 Draft Ada 9X Project Report revealed
> >a new item:
> > S.12.1.4 Generic Formal Packages [new]
> >However, the accompanying description and example leaves out a
> >lot of detail:
>
[Several questions and helpful answers deleted]
> --
> Mark Biggar
> mab@wdl1.wdl.loral.com
Thank you (and I did find the Dec 91 Mapping Spec which helped).
And now to clarify the question I was hopping to get answered. Can
a generic instantiate another generic that is part of a package
specified as a formal argument:
generic
package Template is
generic
with procedure To_Do;
procedure Iterate; -- This generic will eventually be
-- instantiated indirectly
-- when Outer is Instantiated
end Template;
with Template;
generic
with package New_Template is
new Template;
package Outer is
procedure To_Do; -- The essence of what this
-- package does.
procedure Invoke is
new New_Template.Iterate (To_Do); -- !!!!!!
end Outer;
-- The Instantiations:
package Structure is new Template;
package Algorithm is new Outer (Structure);
I think even if code like this example will be allowed in Ada9X,
it will not do what I envisioned. Maybe someone can suggest
how Ada9X might implement a generic Sum utility that uses passive
iteration, without regard to where the iterator comes from:
generic
type Element is limited private;
type List is limited private;
with generic
with procedure To_Do (E : in Element);
procedure Iterate (L : in List);
with procedure Add (Cur : in out Element;
Val : in Element);
procedure Sum (Result : in out Element;
L : in List);
-- Result must be initialized before Sum is called.
procedure Sum (Result : in out Element;
L : in List) is
procedure Add_To_Result (E : in Element) is
begin
Add (Result, Val);
end;
procedure Composition is
new Iterate (Add_To_Result);
begin
Composition (L);
end Sum;
Let me know if there is a better place for this discussion.
Doug
next reply other threads:[~1992-04-13 22:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1992-04-13 22:13 Doug Smith [this message]
-- strict thread matches above, loose matches on Subject: below --
1992-04-08 15:41 Ada 9X plans for Generic Formal Packages Mark A Biggar
1992-04-08 13:02 Arthur Evans
1992-04-07 19:29 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!mips!darwin.sura.net!uvaarpa
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox