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!attcan!uunet!cs.utexas.edu!ut-emx!emx.utexas.edu From: hasan@emx.utexas.edu (David A. Hasan) Newsgroups: comp.lang.ada Subject: layering with discriminants Message-ID: <44963@ut-emx.uucp> Date: 2 Mar 91 00:28:55 GMT Sender: hasan@ut-emx.uucp Organization: UTexas Center for Space Research List-Id: In my struggle to understand how to build layered components in Ada, I have encountered a problem with discriminants. Consider the following "low level" generic component: GENERIC TYPE size IS (<>); PACKAGE g_lowLevel IS TYPE adt (i : size) IS PRIVATE; -- ...other stuff... PRIVATE TYPE adt (i : size) IS RECORD -- ...whatever... END RECORD; END g_lowLevel; Now, add a layer on top as follows: WITH g_lowLevel; GENERIC TYPE length IS (<>); PACKAGE g_highLevel IS TYPE adt (i : length) IS PRIVATE; -- ...other stuff... PRIVATE PACKAGE low_level IS NEW g_lowLevel(length); TYPE adt (i : length) IS NEW low_level.adt(i); ---!!! -- ...whatever... END g_highLevel; This package might provide a different set of operations & semantics for its adt but implement it exactly as the lower level adt. That's the motivation behind what I'm doing: avoid implementing the guts of the adt over. This also factors the design process nicely. My problem revolves around the fact that the DEC compiler rejects the presence of the discriminant in the full declaration of the adt in the private part of g_highLevel, since the declaration is not a record. But the declaration is *derived* from a record. My conclusion is that it is not legal to derive types with discriminants from parents with discriminants. If this is true, is there anyway to achieve an equivalent effect? -- : David A. Hasan : WRW 402 Univ. of Texas at Austin, Austin TX 78712 : internet: hasan@emx.cc.utexas.edu