From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 13 Apr 92 22:13:07 GMT From: terminator!caen!uvaarpa!software.org!smithd@gumby.wisc.edu (Doug Smith) Subject: Re: Ada 9X plans for Generic Formal Packages Message-ID: <1992Apr13.221307.2127@software.org> List-Id: 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