* Tasks with discriminants
@ 1997-12-02 0:00 Larry Coon
1997-12-02 0:00 ` Mats Weber
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Larry Coon @ 1997-12-02 0:00 UTC (permalink / raw)
I've been playing with discriminants for tasks and I
can't get something to work. I can declare a task
such as the following:
task type t (task_no: integer);
And later create actual tasks:
t1: t (1);
t2: t (2);
t3: t (3); -- etc...
But if I want to declare an array of tasks, I
can't figure out how to supply values for the
discriminants:
type task_array is array (1..3) of t;
my_tasks: task_array; -- ????
Can anybody tell me how the discriminants are
supplied in this case? Thanks in advance.
Larry Coon
University of California
larry@assist.org
and lmcoom@home.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Tasks with discriminants
1997-12-02 0:00 Tasks with discriminants Larry Coon
@ 1997-12-02 0:00 ` Mats Weber
1997-12-02 0:00 ` Gerald Kasner
1997-12-11 0:00 ` Joh Harbaugh
2 siblings, 0 replies; 4+ messages in thread
From: Mats Weber @ 1997-12-02 0:00 UTC (permalink / raw)
Larry Coon wrote:
> task type t (task_no: integer);
> But if I want to declare an array of tasks, I
> can't figure out how to supply values for the
> discriminants:
>
> type task_array is array (1..3) of t;
> my_tasks: task_array; -- ????
>
> Can anybody tell me how the discriminants are
> supplied in this case? Thanks in advance.
You can't do this in a way that My_Tasks(i).task_no = i for all i in
My_Tasks'Range. But you can make sure all tasks are initialized with a
distinct value of task_no, and that is described in the Ada 95 Rationale:
<http://www.adahome.com/LRM/95/Rationale/rat95html/rat95-p2-9.html#6>.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Tasks with discriminants
1997-12-02 0:00 Tasks with discriminants Larry Coon
1997-12-02 0:00 ` Mats Weber
@ 1997-12-02 0:00 ` Gerald Kasner
1997-12-11 0:00 ` Joh Harbaugh
2 siblings, 0 replies; 4+ messages in thread
From: Gerald Kasner @ 1997-12-02 0:00 UTC (permalink / raw)
Larry Coon wrote:
>
> type task_array is array (1..3) of t;
> my_tasks: task_array; -- ????
>
> Can anybody tell me how the discriminants are
> supplied in this case? Thanks in advance.
>
try
http://www.seas.gwu.edu/faculty/mfeldman/cs2-book/chap15.html
chap 15.4 Data Structures: The Task as a Data Structure
and proggram 15.7 : Creating an Array of Tasks
--
Gerald
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Tasks with discriminants
1997-12-02 0:00 Tasks with discriminants Larry Coon
1997-12-02 0:00 ` Mats Weber
1997-12-02 0:00 ` Gerald Kasner
@ 1997-12-11 0:00 ` Joh Harbaugh
2 siblings, 0 replies; 4+ messages in thread
From: Joh Harbaugh @ 1997-12-11 0:00 UTC (permalink / raw)
Larry Coon wrote:
>
> I've been playing with discriminants for tasks and I
> can't get something to work. I can declare a task
> such as the following:
>
> task type t (task_no: integer);
>
> And later create actual tasks:
>
> t1: t (1);
> t2: t (2);
> t3: t (3); -- etc...
>
> But if I want to declare an array of tasks, I
> can't figure out how to supply values for the
> discriminants:
>
> type task_array is array (1..3) of t;
> my_tasks: task_array; -- ????
>
> Can anybody tell me how the discriminants are
> supplied in this case? Thanks in advance.
>
> Larry Coon
> University of California
> larry@assist.org
> and lmcoom@home.com
A possibility is to create an array of dynamically allocated task:
Task_Count : constant := 3;
type Task_Ptrs is access all ADC;
-- Raises Program_Error with OA 7.1.105
-- Task_List : array(1..Task_Count) of Task_Ptrs :=
-- (new T(25), new T(20), new T(T15));
Another approach is to use aliased objects:
A : aliased T(25);
B : aliased T(20);
C : aliased T(15);
Task_List : array(1..Task_Count) of T_Ptrs :=
(A'access, B'access, C'access);
In any case, I have not found a way to create an array of static task
objects with discriminants. Perhaps someone else has found a way.
Best regards,
- John
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1997-12-11 0:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-12-02 0:00 Tasks with discriminants Larry Coon
1997-12-02 0:00 ` Mats Weber
1997-12-02 0:00 ` Gerald Kasner
1997-12-11 0:00 ` Joh Harbaugh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox