I'm trying to account for a special case in which several array lengths should be shorter than normal, but where there's no direct relationship between the discriminant and the array lengths. A simplified record might look like this in the normal case:
type Int_Array is array(Integer range <>);
type My_Record is
record
A : Integer;
B : Integer;
C : Int_Array(1..10);
D : Int_Array(1..6);
end record;
But if some discriminant is 320, it should look like this:
type My_Record is
record
A : Integer;
B : Integer;
C : Int_Array(1..4);
D : Int_Array(1..2);
end record;
I've kinda been playing around with it some but can't make anything compile. Here are some things I've tried:
type My_Record(Disc : Positive) is
record
A : Integer;
B : Integer;
C : Int_Array(1..(if Disc = 320 then 4 else 10));
D : Int_Array(1..(if Disc = 320 then 2 else 4));
end record;
But this results in the error "discriminant in constraint must appear alone".
If I try:
type My_Record(Disc : Positive) is
record
A : Integer;
B : Integer;
case Disc is
when 320 =>
C : Int_Array(1..4);
D : Int_Array(1..2);
when others =>
C : Int_Array(1..10);
D : Int_Array(1..4);
end case;
end record;
The definitions of C and D conflict with each other. Is there some other technique I can use for this?