From: "Robert I. Eachus" <rieachus@comcast.net>
Subject: Re: discriminant in constraint must appear alone
Date: Tue, 02 Dec 2003 19:06:42 -0500
Date: 2003-12-02T19:06:42-05:00 [thread overview]
Message-ID: <LOWdnc6Tb_GJtFCi4p2dnA@comcast.com> (raw)
In-Reply-To: <bqiq1m$uis$00$1@news.t-online.com>
Vincent Smeets wrote:
> Are there other possiblities?
There are always other possibilities. ;-)
In this case the rule (RM 3.8(12) is clear on how discriminants can
appear in a record type. You could try:
type R (D2 : Positive) is
record
A1 : String (1 .. D);
A2 : String (1 .. D);
B : String (1 .. D);
end record;
Where A = A1 & A2, and D2 = D/2, or you could use aliasing to map a
string on top of an array (1..D) of Integer_16 elements. But I think
the only reasonable approach for now is to have two discriminants.
Incidently I have tripped over this problem in the past, and I think it
would be wonderful to add three possible uses of discriminants in array
bounds: -D, D + n and n * D, where n is an integer literal. Except for
the first case, a compiler has to be able to generate these types of
expressions and evaluate them at run-time. For example, where does the
value of B start in the type above? Probably at 2*D + 4 bytes from the
start of an object of type R. (Your milage may vary, I am assuming that
for this type the bounds of the arrays are implicit, but that D2 is
stored at the beginning of any objects.)
--
Robert I. Eachus
100% Ada, no bugs--the only way to create software.
next prev parent reply other threads:[~2003-12-03 0:06 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-12-02 19:43 discriminant in constraint must appear alone Vincent Smeets
2003-12-02 20:56 ` Randy Brukardt
2003-12-02 21:15 ` tmoran
2003-12-03 9:06 ` Dmitry A. Kazakov
2003-12-03 0:06 ` Robert I. Eachus [this message]
2003-12-03 21:02 ` Vincent Smeets
2003-12-04 19:16 ` Randy Brukardt
2003-12-05 0:56 ` info version of Ada Reference Manual Stephen Leake
2003-12-05 1:08 ` Stephane Richard
2003-12-05 1:27 ` Ludovic Brenta
2003-12-05 4:36 ` Fionn mac Cuimhaill
2003-12-05 5:28 ` [Totally OT] Nick Roberts
2003-12-05 14:07 ` info version of Ada Reference Manual Stephen Leake
2003-12-05 14:18 ` Arthur Evans Jr
2003-12-05 14:52 ` Stephen Leake
2003-12-07 15:22 ` Arthur Evans Jr
2003-12-05 14:28 ` Georg Bauhaus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox