Array of tasks and using its index as discriminant

Without a default discriminant, the type is indefinite; you can’t declare an object of the type without providing a value for the discriminant:

task type Do_Segmented_Block_Type (Tactic : Segmentation_Tactic);

V : Do_Segmented_Block_Type; -- Illegal

Array components have to be definite. Adding a default discriminant makes the type definite:

task type Do_Segmented_Block_Type (Tactic : Segmentation_Tactic := Segmented_1);

V : Do_Segmented_Block_Type; -- OK, discriminant is Segmented_1

Tasks cannot be mutable.

I don’t see any mention of this “above” in this topic. Am I missing something? There is a reference to this in this topic. While relevant to variant records, it’s not an issue for task types.

1 Like