Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Box notation for array length discriminent in agregates #92

Open
Fabien-Chouteau opened this issue May 12, 2022 · 1 comment
Open

Box notation for array length discriminent in agregates #92

Fabien-Chouteau opened this issue May 12, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@Fabien-Chouteau
Copy link
Member

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".
    1. Would it be possible to allow box notation here?
      return (<>, "This is a lot better");
@Fabien-Chouteau Fabien-Chouteau added the enhancement New feature or request label May 12, 2022
@evanescente-ondine
Copy link

evanescente-ondine commented Oct 16, 2024

Isn't it simpler to initialize the record with a function ? Then with the new String_Literal aspect and 'Image attribute, the use is transparent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants