From: paul@batserver.cs.uq.oz.au (Paul Bailes)
Subject: Instantiating Ada Generic Packages
Date: 29 Mar 90 04:44:22 GMT [thread overview]
Message-ID: <3094@moondance.cs.uq.oz.au> (raw)
Dear colleagues,
I have a problem with Ada generics. Consider the following situation:
package A is
type B is <C.D>;
package C is is new E (B);
end;
and
generic
type F is private;
package E is
type D is private;
private
type G;
type D is access G;
end;
with
package body E is
type G is <F>
end;
(the notation <X> means a code fragment including X)
The problem is that type B depends upon C.D, which itself comes
from the instantiation of E with B - a potential circularity, that
is forbidden by Ada - the above code is (I think) illegal, because
the <C.D> in package A precedes the declaration of C (by the
instantiation of E).
However, the circularity is not an objective problem because C.D
is only an access to the use of B (formal parameter F used in
full type declaration of private G to which D is an access).
From a language designer's point of view, one could imagine a development
of Ada that separated the instantiation of a generic package spec. from
that of the corresponding body: the above would then appear of some form
in which the package spec. instantiates only the generic spec:
package A is
package C is new E (any actual params for the spec. only);
type B is <C.D>;
end;
plus a body that instantiates the generic body:
package body A is
package body C is new E (B);
end;
plus the generic spec. with spec.-only parameters:
generic
any formal params for the spec. only
package E is
type D is private;
private
type G;
type D is access G;
end;
plus the generic body that needs actual param B (from the 1st package spec.)
generic
type F is private;
package body E is
type G is <F>
end;
My questions are
(1) is my perception of my problem a correct one?
(2) why doesn't Ada have separate instantiation of
generic package specs. and bodies?
(3) how can I do what I want WITHOUT having to
expand the generic ``by hand'', in effect to
achieve the separation of instantiations of
specs. and bodies that I desire?
I look forward to reading your solutions on the news!
Thanks in advance,
Paul A. Bailes
Dept. Computer Science
University of Queensland QLD 4072
Australia
next reply other threads:[~1990-03-29 4:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1990-03-29 4:44 Paul Bailes [this message]
1990-03-29 13:55 ` Instantiating Ada Generic Packages Mike Feldman
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox