From: mcc@entropy.cs.princeton.edu (Martin C. Carlisle)
Subject: Re: Thank you
Date: 1999/09/08
Date: 1999-09-08T00:00:00+00:00 [thread overview]
Message-ID: <7r6ea2$pr8$1@cnn.Princeton.EDU> (raw)
In-Reply-To: 7r6acf$imu3@svlss.lmms.lmco.com
It sounds like you did something like the following:
with ada.integer_text_io;
with ada.text_io;
procedure test_discrim is
type bob(discrim : integer := 1) is record
dummy : integer;
end record;
type fred is array(integer range <>) of bob;
x : fred(1..10);
begin
for i in x'range loop
x(i) := bob'(discrim => i, dummy => 0);
end loop;
for i in x'range loop
ada.integer_text_io.put(x(i).discrim);
ada.text_io.new_line;
end loop;
end test_discrim;
But, I still don't see why discrim can't just be a field of the
record. (I guess you do have the advantage that discrim can't
be modified w/o reassigning the entire record.)
--Martin
In article <7r6acf$imu3@svlss.lmms.lmco.com>,
Bruce Detter <bruce.detter@lmco.com> wrote:
>
>Bruce Detter <bruce.detter@lmco.com> wrote in message
>news:7r5vh3$imu1@svlss.lmms.lmco.com...
>> How do you declare an array of variant records where each variant record's
>> descriminant is the array index? Can it be done at all? I would prefer
>not
>> to use access pointers if it can be avoided.
>Thank you for your response, a little experimentation based on Mr. Heaney's
>solution provided the answer. I used a default variant for the array type
>declaration, and "re-initialized" the array elements to what I wanted when
>the array was instanciated.
>
>Professor Carlisle, I have several "message" structures I receive, each with
>1 or more states I need to represent with ascii characters. I wanted to
>have a single place where I could look up the ascii characters up based on
>the message type and state. There is probably several ways I could have
>done this including wrapping the message structure with in a tagged record
>and using polymorphism, but I choose the down and dirty, brute force method
>(for the time being)
--
Martin C. Carlisle, Asst Prof of Computer Science, US Air Force Academy
carlislem@acm.org, http://www.usafa.af.mil/dfcs/bios/carlisle.html
DISCLAIMER: This content in no way reflects the opinions, standards or
policy of the US Air Force Academy or the United States Government.
next prev parent reply other threads:[~1999-09-08 0:00 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-09-08 0:00 Array of Variant Records Question Bruce Detter
1999-09-08 0:00 ` Matthew Heaney
1999-09-08 0:00 ` Mike Silva
1999-09-08 0:00 ` Matthew Heaney
1999-09-09 0:00 ` Robert Dewar
1999-09-09 0:00 ` Matthew Heaney
1999-09-09 0:00 ` Matthew Heaney
1999-09-09 0:00 ` Mark Lundquist
1999-09-09 0:00 ` Robert Dewar
1999-09-09 0:00 ` Robert Dewar
1999-09-09 0:00 ` Brian Rogoff
1999-09-13 0:00 ` Matthew Heaney
1999-09-13 0:00 ` Brian Rogoff
1999-09-14 0:00 ` Robert Dewar
1999-09-14 0:00 ` Robert Dewar
1999-09-14 0:00 ` Brian Rogoff
1999-09-13 0:00 ` Robert A Duff
1999-09-13 0:00 ` Matthew Heaney
1999-09-09 0:00 ` Matthew Heaney
1999-09-10 0:00 ` Mark Lundquist
1999-09-10 0:00 ` Matthew Heaney
1999-09-11 0:00 ` Robert Dewar
1999-09-10 0:00 ` Robert Dewar
1999-09-10 0:00 ` Mark Lundquist
1999-09-10 0:00 ` Matthew Heaney
1999-09-11 0:00 ` Jean-Pierre Rosen
1999-09-14 0:00 ` "cast away const" (was Re: Array of Variant Records Question...) Mark Lundquist
[not found] ` <wccd7viiv59.fsf@world.std.com>
[not found] ` <7rrmqd$l89@drn.newsguy.com>
[not found] ` <wcciu59n2uf.fsf@world.std.com>
1999-09-22 0:00 ` Array of Variant Records Question Robert I. Eachus
1999-09-23 0:00 ` Robert Dewar
1999-09-23 0:00 ` Robert I. Eachus
1999-09-22 0:00 ` Robert I. Eachus
1999-09-11 0:00 ` Richard D Riehle
1999-09-13 0:00 ` Hyman Rosen
1999-09-14 0:00 ` Mark Lundquist
[not found] ` <7roohh$s6r@dfw-ixnews7.ix.netcom.com>
[not found] ` <37e01168@news1.prserv.net>
[not found] ` <7rp86o$c6h@dfw-ixnews3.ix.netcom.com>
[not found] ` <37E18CC6.C8D431B@rational.com>
[not found] ` <7rs8bn$s6@dfw-ixnews4.ix.netcom.com>
[not found] ` <wccemfxn15s.fsf@world.std.com>
1999-09-22 0:00 ` 'constant functions' and access constant params (was Re: Array of Variant Records Question...) Richard D Riehle
[not found] ` <37e2e58c@news1.prserv.net>
1999-09-22 0:00 ` Richard D Riehle
1999-09-22 0:00 ` Matthew Heaney
1999-09-22 0:00 ` Richard D Riehle
1999-09-22 0:00 ` Matthew Heaney
1999-09-23 0:00 ` Vincent Marciante
1999-09-23 0:00 ` Matthew Heaney
1999-09-24 0:00 ` Robert A Duff
1999-09-25 0:00 ` Matthew Heaney
1999-09-27 0:00 ` Richard D Riehle
1999-09-27 0:00 ` Richard D Riehle
1999-09-27 0:00 ` David Kristola
1999-09-22 0:00 ` Matthew Heaney
1999-09-23 0:00 ` Robert Dewar
1999-09-27 0:00 ` Richard D Riehle
1999-09-28 0:00 ` Robert Dewar
1999-09-28 0:00 ` Richard D Riehle
1999-09-29 0:00 ` Robert A Duff
1999-09-29 0:00 ` Robert Dewar
1999-09-28 0:00 ` Robert Dewar
1999-09-28 0:00 ` "Competence" (was: 'constant functions' and access constant params) Ted Dennison
1999-09-28 0:00 ` Robert Dewar
1999-09-22 0:00 ` 'constant functions' and access constant params (was Re: Array of Variant Records Question...) Mark Lundquist
1999-09-22 0:00 ` Mark Lundquist
1999-09-10 0:00 ` Proposed Ada features " Mark Lundquist
1999-09-10 0:00 ` Matthew Heaney
1999-09-10 0:00 ` tmoran
1999-09-09 0:00 ` Array of Variant Records Question Nick Roberts
1999-09-09 0:00 ` Tucker Taft
1999-09-10 0:00 ` Nick Roberts
1999-09-09 0:00 ` Robert Dewar
1999-09-08 0:00 ` Thank you Bruce Detter
1999-09-08 0:00 ` Martin C. Carlisle [this message]
1999-09-08 0:00 ` Array of Variant Records Question Martin C. Carlisle
1999-09-08 0:00 ` Ted Dennison
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox