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.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1b8bb636c4056425 X-Google-Attributes: gid103376,public From: David C. Hoos, Sr. Subject: Re: Using an array of variant records Date: 2000/01/27 Message-ID: <86qg16$ug3$1@nnrp1.deja.com>#1/1 X-Deja-AN: 578438969 References: <389089CB.85F9FF72@silver.jhuapl.edu> To: scott@silver.jhuapl.edu X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt) X-Http-Proxy: 1.1 x42.deja.com:80 (Squid/1.1.22) for client 205.149.60.17 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Thu Jan 27 22:15:08 2000 GMT X-MyDeja-Info: XMYDJUIDdhoossr Newsgroups: comp.lang.ada Date: 2000-01-27T00:00:00+00:00 List-Id: In article <389089CB.85F9FF72@silver.jhuapl.edu>, Scott Ingram wrote: > What I would like to do is to treat a set of variant records > as an array. The discrimanant of the records is unconstrained, > but I seem unable to access it when trying to initialize the > record as element of an array. The example below illustrates > what I want to accomplish, but gnat complains that it expects > a selector at the point that I want to select the discriminant. > > Is it possible to do what I want? > > procedure snake_test is > type snake is (garter, green); > type snake_health is > record > Shed : Boolean; > Active : Boolean; > end record; > type captive_snake (caged : Boolean := False) is > record > snake_kind : snake; > case caged is > when true => > health : snake_health; > when others => > null; > end case; > end record; > type snake_array is array (1..3) of captive_snake; > S1 : snake_array; > begin > for i in 1..3 loop > S1(i).(caged => True, > snake_kind => green, > health => (shed => true, active => true)); > end loop; > end snake_test; > > Output from gnat: > > Compiling: snake_test.adb (source file time stamp: 2000-01-27 18:07:28) > 22. S1(i).(caged => True, > | > >>> selector expected > > Is there something that I have overlooked? Yes. The expression to the right of the dot is not a selector, but an aggregate. I believe you wanted : S1(i) := (caged => True, snake_kind => green, health => (shed => true, active => true)); Sent via Deja.com http://www.deja.com/ Before you buy.