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-Thread: a07f3367d7,d00514eb0749375b X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!feeder.news-service.com!takemy.news.telefonica.de!telefonica.de!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Thu, 11 Nov 2010 02:07:39 +0100 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.12) Gecko/20101027 Thunderbird/3.1.6 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: initialize an array (1-D) at elaboration using an expression based on the index? References: <4b8f7f06-a817-4545-9fc6-67740c67b9d3@a4g2000prm.googlegroups.com> <4cdaad27$0$6979$9b4e6d93@newsspool4.arcor-online.net> <82e746ff-a4eb-4570-8016-78930977def1@35g2000prb.googlegroups.com> In-Reply-To: <82e746ff-a4eb-4570-8016-78930977def1@35g2000prb.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <4cdb41db$0$6980$9b4e6d93@newsspool4.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 11 Nov 2010 02:07:40 CET NNTP-Posting-Host: b0c5bd1e.newsspool4.arcor-online.net X-Trace: DXC=kON4H><3R`0lIh70@ejV8mB\dg On 11/10/10 4:51 PM, Adam Beneschan wrote: >> Jobs : array (Job_Id) of T := (for D in Job_Id => ???(D)); >> >> ... > ... But I think you can set up a function: > > function Task_With_ID (Identity : Job_ID := No_Job) return T is > begin > return X : T(Identity); > end; > > and use that in your aggregate: > > Single_Job : aliased Rec := (Task_With_ID(J), null); > > Warning: I have not tried this. Tested with GNAT GPL 2010, it works. In particular, Jobs : array (Job_Id) of T := (others => Make); works, where construction function Make advances Job_Id values for T's discriminant internally. The setup is less static, though. The (for ...) syntax will leave little doubt as to which index values Make (or something in its place) is using to produce a T object. That is not obvious now. (All as long a T can have a default discriminant.) Just an ad-hoc idea: Jobs : array (X: Job_Id) of T := (others => Make(X)); where X: Job_Id is a little like a record discriminant passed on to constrain components, for example, only with a different "multiplicity".