comp.lang.ada
 help / color / mirror / Atom feed
From: "Joe" <sorry@no.email>
Subject: Allocate an array of a record with a discriminant?
Date: Tue, 27 Mar 2001 16:41:31 +0100
Date: 2001-03-27T16:41:31+01:00	[thread overview]
Message-ID: <tc1ghv4o7s23e2@corp.supernews.co.uk> (raw)

Dear all,

I'd appreciate it greatly if any of you could answer the following question.

Basically, I want to create an array of English words. The following
information will be given before the words are typed in, _but_ not before
runtime:

- the maximum length of any one word (the Max_Length variable will contain
it)
- the number of words to be given (Num_Words)

A word would be described by something like the following type:

type Word (Max_Length : Integer) is
record
 Length : Integer;
 S : String (1 .. Max_Length);
end record;

As I understand it, using discriminants with arrays is not possible such as:

type Words (Max_Word_Length : Integer) is array (Natural range <>) of Word
(Max_Word_Length);

How is it possible to allocate space for an array of type "Word" where all
are of the same "Word.Length" which is "Max_Length" at runtime?

Keep in mind that Max_Length and Num_Words are given at runtime, not before.

Thanks in advance,

Joe






             reply	other threads:[~2001-03-27 15:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-27 15:41 Joe [this message]
2001-03-27 20:22 ` Allocate an array of a record with a discriminant? Robert A Duff
2001-03-27 21:11 ` tmoran
2001-03-30 18:48 ` Mark Lundquist
2001-03-31  4:22   ` Robert A Duff
  -- strict thread matches above, loose matches on Subject: below --
2001-03-27 19:44 Beard, Frank
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox