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!news1.google.com!news.glorb.com!fr.ip.ndsoftware.net!news2.euro.net!62.253.162.219.MISMATCH!newsrout1.ntli.net!news-in.ntli.net!news-hub.cableinet.net!blueyonder!news-text.cableinet.net!53ab2750!not-for-mail From: "Karen" Newsgroups: comp.lang.ada References: <40ACC50E.9040406@mail.usyd.edu.au> <2iceofFlgn4pU1@uni-berlin.de> Subject: Re: Task discriminants X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Message-ID: Date: Mon, 07 Jun 2004 22:12:29 GMT NNTP-Posting-Host: 82.43.168.238 X-Complaints-To: abuse@blueyonder.co.uk X-Trace: news-text.cableinet.net 1086646349 82.43.168.238 (Mon, 07 Jun 2004 23:12:29 BST) NNTP-Posting-Date: Mon, 07 Jun 2004 23:12:29 BST Organization: blueyonder (post doesn't reflect views of blueyonder) Xref: g2news1.google.com comp.lang.ada:1218 Date: 2004-06-07T22:12:29+00:00 List-Id: Or the obvious approach, to declare a access type to the task type. Then have an array of those access types, which are initialised using different discriminants as you need. (from a posting newbie, but an Ada Graybeard) ian(dot)nussbaum(at)blueyonder.co.uk "Nick Roberts" wrote in message news:2iceofFlgn4pU1@uni-berlin.de... > "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 > >