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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ec4a7355f321a22b X-Google-Attributes: gid103376,public Path: g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!news.tu-darmstadt.de!fu-berlin.de!uni-berlin.de!not-for-mail From: "Nick Roberts" Newsgroups: comp.lang.ada Subject: Re: Task discriminants Date: Sat, 5 Jun 2004 00:26:07 +0100 Message-ID: <2iceofFlgn4pU1@uni-berlin.de> References: <40ACC50E.9040406@mail.usyd.edu.au> X-Trace: news.uni-berlin.de YuBhlfI2Lu5Wt6pwGdG4ngpQEKJ18bc8wnXKictyXFDoaFfqs= X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 Xref: g2news1.google.com comp.lang.ada:1112 Date: 2004-06-05T00:26:07+01:00 List-Id: "Dave Levy" wrote in message news:40ACC50E.9040406@mail.usyd.edu.au... > Suppose one has a task type with a discriminant: > > task type A_Task( Id : integer); > > and one wishes to declare a set of tasks with initialised discriminants: > t1 : A_Task(1); > t2 : A_Task(2); > t3 : A_Task(3); > > How could one declare them as an array of tasks with each one getting an > initialised discriminant? Perhaps something like: > > The_Tasks: array (1..3) of A_Task( Id => 1,2,3 ); > > Except I tried this with Gnat and it won't compile. It is a basic precept of Ada arrays that its components are all of the same subtype. This means that they cannot have different discriminants. So this approach, as such, is doomed. You could use the 'old' technique: type A_Task_Number is range 1..3; task type A_Task is entry Init (Num: in A_Task_Number); ... end; The_Tasks: array (A_Task_Number) of A_Task; ... for i in A_Task_Number loop The_Tasks(i).Init(i); end loop; ... task body A_Task is My_Num: A_Task_Number; ... begin accept Init (Num: in A_Task_Number) do My_Num := Num; end; ... end A_Task; It's always worked for me! -- Nick Roberts