From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!samsung!munnari.oz.au!metro!bunyip!moondance!batserver.cs.uq.oz.au!paul From: paul@batserver.cs.uq.oz.au (Paul Bailes) Newsgroups: comp.lang.ada Subject: Instantiating Ada Generic Packages Message-ID: <3094@moondance.cs.uq.oz.au> Date: 29 Mar 90 04:44:22 GMT Sender: news@moondance.cs.uq.oz.au Reply-To: paul@batserver.cs.uq.oz.au List-Id: Dear colleagues, I have a problem with Ada generics. Consider the following situation: package A is type B is ; 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 end; (the notation 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 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 ; 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 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