From: Jere <jhb.chat@gmail.com>
Subject: Initializing an array of tasks with discrimants
Date: Fri, 22 Nov 2019 14:07:47 -0800 (PST)
Date: 2019-11-22T14:07:47-08:00 [thread overview]
Message-ID: <358a3934-7cb2-4cff-8703-71410815f27e@googlegroups.com> (raw)
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:
task type T(D: Integer := 3);
task body T is
begin
null;
end T;
type A is array (Integer range <>) of T;
V : A(1..10) := ?????????
If they all had the same discriminant value, I
can just create a subtype and do an array of
the subtype, but in this case, the discriminants
would not all be the same.
My work around was a wrapper type:
type Wrapper(D : Integer := 0) is record
Impl : T(D);
end record.
type A is array (Integer range <>) of Wrapper;
V : A(1..10) := (1 => (D => 1, others => <>), and so on
But I was hoping there was a better way to do it simply.
The Wrapper record isn't there to represent the
intended design and doesn't really improve readability.
It's essentially a workaround for something I cannot
figure out.
I tried many variations of qualified expressions and
aggregates on the original task type elements, but all
of them gave me errors about it expected the task type
but found a composite type instead.
Is there a particular aggregate that I can use to avoid
the superfluous wrapper record?
next reply other threads:[~2019-11-22 22:07 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-22 22:07 Jere [this message]
2019-11-22 22:39 ` Initializing an array of tasks with discrimants Jeffrey R. Carter
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