To be able to have String or any other kind of unconstrained array in a record I often use the following pattern:
type Data (Str_Len : Natural) is record
Str : String (1 .. Str_Len);
end record;
This is convenient and works for me most of the time. However one annoying aspect is that when writing an aggregate one has to update the discriminant when changing the string.
It's ok for short strings:
return (4, "test");
return (4, "But it is annoying for long string");
So I have two suggestions to discuss here:
1) I think the compiler error could be improved to give the expected value for the discriminant instead of just saying "wrong length for array".
2) Would it be possible to allow box notation here?
To be able to have String or any other kind of unconstrained array in a record I often use the following pattern:
This is convenient and works for me most of the time. However one annoying aspect is that when writing an aggregate one has to update the discriminant when changing the string. It's ok for short strings:
So I have two suggestions to discuss here: