From: hasan@emx.utexas.edu (David A. Hasan)
Subject: layering with discriminants
Date: 2 Mar 91 00:28:55 GMT [thread overview]
Message-ID: <44963@ut-emx.uucp> (raw)
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
next reply other threads:[~1991-03-02 0:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1991-03-02 0:28 David A. Hasan [this message]
1991-03-04 2:52 ` layering with discriminants Joe Hollingsworth
1991-03-06 20:12 ` stt
1991-03-05 1:56 ` Robert I. Eachus
-- strict thread matches above, loose matches on Subject: below --
1991-03-05 18:00 Dave Williamson
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox