From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,321833745abc5bf3 X-Google-Attributes: gid103376,public From: Joh Harbaugh Subject: Re: Tasks with discriminants Date: 1997/12/11 Message-ID: <34905735.13A8@boeing.com>#1/1 X-Deja-AN: 297340631 Sender: nntp@news.boeing.com (Boeing NNTP News Access) X-Nntp-Posting-Host: e582750.knt.boeing.com References: <3483C38C.1FF2@home.com> Organization: The Boeing Company Newsgroups: comp.lang.ada Date: 1997-12-11T00:00:00+00:00 List-Id: 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