I've got a task type with a discriminant:
type Index is range 1 .. N;
task type T (D: Index);
Now I want an array of these tasks, where each task knows its
identity (the index) via the discriminant, an
iterated_component_association: >
Arr: array (Index) of T := (for I in Index => ???);
How can I do this?
On 2022-12-24 13:44, AdaMagica wrote:
Now I want an array of these tasks, where each task knows its identity (the >> index) via the discriminant, an
iterated_component_association: >
Arr: array (Index) of T := (for I in Index => ???);
One way is to give the discrimant a default value that is a function call that
returns a new identifier on each call:
On 2022-12-24 19:05, Niklas Holsti wrote:
On 2022-12-24 13:44, AdaMagica wrote:
Now I want an array of these tasks, where each task knows its
identity (the index) via the discriminant, an
iterated_component_association: >
Arr: array (Index) of T := (for I in Index => ???);
One way is to give the discrimant a default value that is a function
call that returns a new identifier on each call:
No, this does not guarantee that the task's discriminant is its index in
the array, which is a requirement of the question.
I've got a task type with a discriminant:
type Index is range 1 .. N;
task type T (D: Index);
Now I want an array of these tasks, where each task knows its
identity (the index) via the discriminant, an iterated_component_association:
Arr: array (Index) of T := (for I in Index => ???);
How can I do this?
This works with access, but I find this extremely ugly:
Arr: array (Index) of access T := (for I in Index => new T (I));
Alternatively, I could use the traditional method with a Start entry with the index as parameter:
task type T is
entry Start (D: Index);
end T;
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 351 |
Nodes: | 16 (2 / 14) |
Uptime: | 37:52:14 |
Calls: | 7,634 |
Files: | 12,797 |
Messages: | 5,689,552 |