* Re: Ada 9X plans for Generic Formal Packages
@ 1992-04-08 13:02 Arthur Evans
0 siblings, 0 replies; 4+ messages in thread
From: Arthur Evans @ 1992-04-08 13:02 UTC (permalink / raw)
smithd@software.org (Doug Smith) asks about generic formal packages in
Ada 9X.
Smith cites (incompletely)
Ada 9X Mapping Document Volume I: Mapping Rationale, March 1992
in which Section S.12.1.4 provides the rationale for a new feature. He
then asks for more information about that feature.
See
Ada 9X Mapping Specifucation Volume II: Mapping Specification,
December 1991.
(This is MS 4.0, version 4.0 of the Mapping Specification.) The feature
in question is described in section 12.1.4. You will find there all the
information you need.
Art Evans
----------------------------------------------
Arthur Evans, Jr, PhD Ada Consultant
461 Fairview Road
Pittsburgh PA 15238-1933
412-963-0839
ae@sei.cmu.edu
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Ada 9X plans for Generic Formal Packages
@ 1992-04-13 22:13 Doug Smith
0 siblings, 0 replies; 4+ messages in thread
From: Doug Smith @ 1992-04-13 22:13 UTC (permalink / 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Ada 9X plans for Generic Formal Packages
@ 1992-04-08 15:41 Mark A Biggar
0 siblings, 0 replies; 4+ messages in thread
From: Mark A Biggar @ 1992-04-08 15:41 UTC (permalink / raw)
In article <1992Apr7.192922.24708@software.org> smithd@software.org (Doug Smith
) 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:
> o How does the generic instantiate the formal package
> (named associations, etc.?)
It doesn't. The actual argument to a generic instantiation with a generic
formal package parameter is an already instantiated package, which must
be an instance of the generic package specified in the generic formal part.
For example:
------------------------------------------------
generic
type FLOAT_T is digits <>;
package Gen_Complex is
... -- defines type COMPLEX, +, -, *, etc.
end Gen_Complex;
generic
with package Complex is
new Gen_Complex(<>);
package Gen_Complex_Functions is
... -- defines sin, cos, exp, log, etc
end Gen_Complex_Functions;
type MY_FLOAT is digits 23;
package MY_COMPLEX is new Gen_Complex(MY_FLOAT);
package MY_COMPLEX_FUNCTIONS is new Gen_Complex_Functions(MY_COMPLEX);
---------------------------------------------------
Note that the actual argument to Gen_Complex_Functions in the final
instantiation is the already instantiated package MY_COMPLEX.
> o How are the profiles of the actual packages mapped
> to the profiles of the generic formal packages?
By requiring that the actual argument to the generic be only instantiations
of the given formal generic package, no mapping is necessary as all possible
arguments have identical profiles.
> o How will defaults work?
They don't as there are no defaults for generic formal package parameters.
>Can anyone point me to further information concerning this
>feature. I have suggested something similar to several
>people and see a great deal of power behind it--if it
>really is what it appears to be: Providing generic
>packages as formal parameters to generic packages!
--
Mark Biggar
mab@wdl1.wdl.loral.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Ada 9X plans for Generic Formal Packages
@ 1992-04-07 19:29 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!mips!darwin.sura.net!uvaarpa
0 siblings, 0 replies; 4+ messages in thread
From: cis.ohio-state.edu!zaphod.mps.ohio-state.edu!mips!darwin.sura.net!uvaarpa @ 1992-04-07 19:29 UTC (permalink / raw)
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:
o How does the generic instantiate the formal package
(named associations, etc.?)
o How are the profiles of the actual packages mapped
to the profiles of the generic formal packages?
o How will defaults work?
Can anyone point me to further information concerning this
feature. I have suggested something similar to several
people and see a great deal of power behind it--if it
really is what it appears to be: Providing generic
packages as formal parameters to generic packages!
Doug
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1992-04-13 22:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1992-04-08 13:02 Ada 9X plans for Generic Formal Packages Arthur Evans
-- strict thread matches above, loose matches on Subject: below --
1992-04-13 22:13 Doug Smith
1992-04-08 15:41 Mark A Biggar
1992-04-07 19:29 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!mips!darwin.sura.net!uvaarpa
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox