* generic arrays?
@ 2004-02-20 15:58 chris
2004-02-20 17:03 ` Jeffrey Carter
2004-02-20 21:06 ` Jim Rogers
0 siblings, 2 replies; 4+ messages in thread
From: chris @ 2004-02-20 15:58 UTC (permalink / raw)
Hi,
Is it possible to do something like the following?
generic
NI : Positive;
package P is
type IV is array (1..NI) of float;
end P;
generic
type X is ...
package T is
type TP is record
A : X;
end TP;
end T;
with the ability to make the type of X = type of IV? I want to
instansiate T with IV after instantiating P, but don't know what to make
X. Is there any way to avoid using an access type to hold X in the
record TP? (in the case where type x is an unconstrained array of floats).
Cheers,
Chris
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: generic arrays?
2004-02-20 15:58 generic arrays? chris
@ 2004-02-20 17:03 ` Jeffrey Carter
2004-02-22 16:44 ` chris
2004-02-20 21:06 ` Jim Rogers
1 sibling, 1 reply; 4+ messages in thread
From: Jeffrey Carter @ 2004-02-20 17:03 UTC (permalink / raw)
chris wrote:
> Is it possible to do something like the following?
>
> generic
> NI : Positive;
> package P is
> type IV is array (1..NI) of float;
> end P;
>
> generic
> type X is ...
> package T is
> type TP is record
> A : X;
> end TP;
> end T;
>
> with the ability to make the type of X = type of IV? I want to
> instansiate T with IV after instantiating P, but don't know what to make
> X. Is there any way to avoid using an access type to hold X in the
> record TP? (in the case where type x is an unconstrained array of floats).
I must be misunderstanding something, because this seems easy and basic:
generic
type X is [limited] private;
package T is
...
with P;
with T;
procedure W is
package New_P is new P (Ni => 10);
package New_T is new T (X => New_P.Iv);
Q : New_T.Tp;
...
--
Jeff Carter
"C++ is like jamming a helicopter inside a Miata
and expecting some sort of improvement."
Drew Olbrich
51
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: generic arrays?
2004-02-20 15:58 generic arrays? chris
2004-02-20 17:03 ` Jeffrey Carter
@ 2004-02-20 21:06 ` Jim Rogers
1 sibling, 0 replies; 4+ messages in thread
From: Jim Rogers @ 2004-02-20 21:06 UTC (permalink / raw)
chris <spamoff.danx@ntlworld.com> wrote in message news:<f4qZb.72$b_4.18@newsfe1-win>...
> Hi,
<snip>
> with the ability to make the type of X = type of IV? I want to
> instansiate T with IV after instantiating P, but don't know what to make
> X. Is there any way to avoid using an access type to hold X in the
> record TP? (in the case where type x is an unconstrained array of floats).
Try a discriminated record rather than a generic.
type Foo_Array is array(Positive range <>) of float;
type TP (Max : Positive) is record
X : Foo_Array(1..Max);
end record;
Jim Rogers
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: generic arrays?
2004-02-20 17:03 ` Jeffrey Carter
@ 2004-02-22 16:44 ` chris
0 siblings, 0 replies; 4+ messages in thread
From: chris @ 2004-02-22 16:44 UTC (permalink / raw)
Jeffrey Carter wrote:
> I must be misunderstanding something, because this seems easy and basic:
You're right, it is! Thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-02-22 16:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-20 15:58 generic arrays? chris
2004-02-20 17:03 ` Jeffrey Carter
2004-02-22 16:44 ` chris
2004-02-20 21:06 ` Jim Rogers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox