* can a record contain an array whose bounds are not known at compi le time?
@ 2002-10-25 14:05 Yu, Liyang
2002-10-25 15:10 ` Robert A Duff
0 siblings, 1 reply; 2+ messages in thread
From: Yu, Liyang @ 2002-10-25 14:05 UTC (permalink / raw)
Hi,
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?
Thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: can a record contain an array whose bounds are not known at compi le time?
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
0 siblings, 0 replies; 2+ messages in thread
From: Robert A Duff @ 2002-10-25 15:10 UTC (permalink / raw)
"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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-10-25 15:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox