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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Received: by 2002:a0c:c125:: with SMTP id f34mr8150086qvh.22.1574526502451; Sat, 23 Nov 2019 08:28:22 -0800 (PST) X-Received: by 2002:a9d:66a:: with SMTP id 97mr15019765otn.114.1574526502226; Sat, 23 Nov 2019 08:28:22 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!g89no2814190qtd.0!news-out.google.com!p4ni1612qtu.1!nntp.google.com!g89no2814180qtd.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 23 Nov 2019 08:28:22 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=70.109.61.2; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf NNTP-Posting-Host: 70.109.61.2 References: <358a3934-7cb2-4cff-8703-71410815f27e@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <91db9356-1b6a-4426-a9c7-c19613c654e8@googlegroups.com> Subject: Re: Initializing an array of tasks with discrimants From: Jere Injection-Date: Sat, 23 Nov 2019 16:28:22 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader01.eternal-september.org comp.lang.ada:57602 Date: 2019-11-23T08:28:22-08:00 List-Id: On Saturday, November 23, 2019 at 3:29:45 AM UTC-5, Dmitry A. Kazakov wrote: > On 2019-11-22 23:07, Jere wrote: > > 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); > > The cleanest way would be a protected generator of unique task IDs: > > protected ID is > procedure Get (ID : out Integer); > private > Free : Integer := 0; > end ID; > > procedure Get (ID : out Integer) is > begin > ID := Free; > Free := Free + 1; > end Get; > > task body T is > D : Integer; > begin > ID.Get (D); > ... > end T; > > No discriminants. > > -- > Regards, > Dmitry A. Kazakov > http://www.dmitry-kazakov.de Yes, for ID's. I really dialed down the example code for simplicity. The actual scenario isn't ID's but a set of enumerations that provide configuration data for the tasks. They wouldn't be unique or in any order. I was mostly just seeing if I could do away with the wrapper record for initialization.