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.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!grebyn.com!karl From: karl@grebyn.com (Karl Nyberg) Newsgroups: comp.lang.ada Subject: Limited types and generic parameters Message-ID: <8902230551.AA02866@grebyn.com> Date: 23 Feb 89 05:51:18 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: Grebyn Corporation List-Id: [Ed - forwarded] -- Karl -- Mats Weber asks: >> Consider the following piece of Ada code: >> >> generic >> type T is limited private; >> package GP is >> >> type R is >> record >> F : T; >> end record; >> >> end GP; >> >> package P is new GP(T => INTEGER); >> >> X : P.R := (F => 45); -- * >> Y : P.R := (F => 77); -- * >> Are the *-marked assignments correct ? In other words, is P.R a limited >> type ? AI-398 answers a similar question for arrays: ... If the component type of an array type is a generic formal type or if the designated type of an access type is a generic formal type, the operations declared for the array and access type in the template depend on the class of the formal type. If the array and access type declarations do not occur in the generic formal part, then the operations declared for these types in a generic instance are determined by the type denoted by the formal parameter in the instance. This means that if type R in the example were an array type with component type T, assignments to an object of type R declared in the template would not be allowed, but assignments to an object declared elsewhere (or in an instance) would be okay as long as the actual type is not limited. The reasoning underlying this interpretation for arrays extends to record types, although these types were not addressed explicitly in the AI. So, in short, the assignments in the example are considered legal. Whether compilers support AI-398 is another question. I don't think any tests on this point exist in the ACVC suite, and even if they did, the test objectives on this point are (or were) not consistent with AI-398. But since AI-398 is an approved commentary, compilers ought to support the kind of assignments indicated in the question. There are a number of other, rather subtle, issues raised in AI-398 related to the effects of type derivation, but AI-398 follows the principal that the appropriate operations are declared in the instance, even if the operations do not exist in the template. John B. Goodenough Goodenough@sei.cmu.edu Software Engineering Institute 412-268-6391