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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,a875277ea50f811b,start X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!w41g2000yqb.googlegroups.com!not-for-mail From: Gautier write-only Newsgroups: comp.lang.ada Subject: Record type as generic parameter Date: Thu, 13 Aug 2009 02:52:52 -0700 (PDT) Organization: http://groups.google.com Message-ID: <2698b15a-7a94-45b5-90af-d0fb5929b1cf@w41g2000yqb.googlegroups.com> NNTP-Posting-Host: 206.122.158.4 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1250157172 24632 127.0.0.1 (13 Aug 2009 09:52:52 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 13 Aug 2009 09:52:52 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: w41g2000yqb.googlegroups.com; posting-host=206.122.158.4; posting-account=gRqrnQkAAAAC_02ynnhqGk1VRQlve6ZG User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/530.5 (KHTML, like Gecko) Chrome/2.0.172.39 Safari/530.5,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:7717 Date: 2009-08-13T02:52:52-07:00 List-Id: Hello, Let's say I have an enumerated type called Scenario, and I want to fill some data structure with the following information: for each scenario, I have a certain number of items (of a defined type), which is varying according to the scenario. That information is stored in an array with pairs (scenario, item). An item might by appearing in several scenarios, it is why I don't have simply an array(Item) of Scenario. Everything fine up to now. Now, I would like to make it generic, since I have several sets of scenario - i.e. different enumerated types like Scenario. Then, my favourite Ada compiler doesn't want a record as generic parameter: generic type Scenario is range <>; type Association is record scen: Scenario; it : Item; end record; scenario_definition: array(Positive range <>) of Association; procedure Fill_Scenarios; Any nice workaround ? A not-so-nice one is to have two arrays, one array of Scenario, one array of Item. Ideally I would keep the type like Association above. XY_scenario_definition: constant array(Positive range <>) of XY_Association:= ( (Scen_abc, Item_56), (Scen_abc, Item_345), (Scen_uvw, Item_12), .. The data are easier to pump from a database directly as Ada sources, they are then easier to read, and there is no chance of messing positions as with the two arrays solution. TIA _________________________________________________________ Gautier's Ada programming -- http://sf.net/users/gdemont/ NB: For a direct answer, e-mail address on the Web site!