From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Initializing an array of tasks with discrimants
Date: Fri, 22 Nov 2019 23:39:53 +0100
Date: 2019-11-22T23:39:53+01:00 [thread overview]
Message-ID: <qr9o3p$4hd$1@dont-email.me> (raw)
In-Reply-To: <358a3934-7cb2-4cff-8703-71410815f27e@googlegroups.com>
On 11/22/19 11:07 PM, Jere wrote:
> I recently ran into a situation where I had an array
> of tasks that had discriminants (with a default), but
> I couldn't find a simple way to initialize them. I
> did come up with a workaround, but wanted to see if
> the language defined a way to do this:
The standard way to do this is for the default to be a function call:
Next_Value : Positive := 1;
function Next return Positive is
Result : constant Positive := Next_Value;
begin -- Next
Next_Value := Next_Value + 1;
return Result;
end Next;
task type T (D : Positive := Next);
type T_List is array (Positive range <>) of T;
A : T_List (1 .. Num_Tasks);
The language guarantees that the calls to Next will occur sequentially. The
order of the calls is not defined, so there is no guarantee that the index and
discriminant of a T in A will be the same.
--
Jeff Carter
"I would never want to belong to any club that
would have someone like me for a member."
Annie Hall
41
next prev parent reply other threads:[~2019-11-22 22:39 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-22 22:07 Initializing an array of tasks with discrimants Jere
2019-11-22 22:39 ` Jeffrey R. Carter [this message]
2019-11-23 16:23 ` Jere
2019-11-22 23:57 ` Robert A Duff
2019-11-23 0:27 ` Anh Vo
2019-11-23 9:12 ` Randy Brukardt
2019-11-23 16:50 ` Jere
2019-11-23 16:25 ` Jere
2019-11-23 8:29 ` Dmitry A. Kazakov
2019-11-23 16:28 ` Jere
2019-11-23 17:03 ` Dmitry A. Kazakov
2019-11-23 16:57 ` Jere
2019-11-25 22:36 ` Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox