comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: can a record contain an array whose bounds are not known at compi le time?
Date: Fri, 25 Oct 2002 15:10:49 GMT
Date: 2002-10-25T15:10:49+00:00	[thread overview]
Message-ID: <wcchefak0zq.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: mailman.1035554821.6971.comp.lang.ada@ada.eu.org

"Yu, Liyang" <Liyang.Yu@delta.com> writes:

> I need to use an array in a record and this array's bound is not known at
> compile time. Can Ada do this? Can someone give me a example about how to do
> this or any reference that I can use?

If the array always has the *same* bounds, then you just use those
bounds (even if not compile-time known):

    subtype My_String is String(A..B);

    type T is
        record
            X: My_String;

A and B can depend on input data, for example.

If different records of the type have different-length arrays,
but the length doesn't change once created, use a discriminant
as suggested in another post.

If the length of the arrays changes over time, you must simulate that
using a pointer.

- Bob



      reply	other threads:[~2002-10-25 15:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-25 14:05 can a record contain an array whose bounds are not known at compi le time? Yu, Liyang
2002-10-25 15:10 ` Robert A Duff [this message]
replies disabled

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