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=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.42.85.142 with SMTP id q14mr9172756icl.16.1403540817939; Mon, 23 Jun 2014 09:26:57 -0700 (PDT) X-Received: by 10.50.77.112 with SMTP id r16mr416801igw.3.1403540817855; Mon, 23 Jun 2014 09:26:57 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!news.glorb.com!hn18no7212480igb.0!news-out.google.com!gf2ni11igb.0!nntp.google.com!hn18no7212473igb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 23 Jun 2014 09:26:57 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=KSa2aQoAAACOxnC0usBJYX8NE3x3a1Xq NNTP-Posting-Host: 66.126.103.122 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Function definitions - with clarification From: Adam Beneschan Injection-Date: Mon, 23 Jun 2014 16:26:57 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:20559 Date: 2014-06-23T09:26:57-07:00 List-Id: On Sunday, June 22, 2014 4:34:09 AM UTC-7, montgrimpulo wrote: > type Individual (P, Q, R) is record=20 > X : x_array (0..P);=20 > Y : y_array (0..Q);=20 > Z : z_array (0..R);=20 > end record;=20 > -- type population is array (1 .. Popsize) of Individual;=20 > -- gives: unconstrained element in array declaration=20 If you are trying to set up an array of Individuals where the Individuals c= ould all have different discriminants: you can't do that in Ada. Sorry. T= he reason is that to set up an array, the elements all have to be the same = size, and an Individual(P=3D>3, Q=3D>5, R=3D>4) will have a different size = than an Individual(P=3D>2, Q=3D>2, R=3D>1). [That may not be true on all c= ompilers. But the language was designed so that it would work on compilers= that do allocate different sizes for those different records.] If this is what you want, you will have to start using access types. I.e. type Individual_Acc is access Individual; type population is array (1 .. Popsize) of Individual_Acc; Now, all the array elements are accesses (pointers), so they will have the = same size. If you want a Population where each Individual has the **same** discriminan= ts, you could get it to work by putting discriminants on the array. The pr= oblem is that you can't put discriminants on an array, but you can put them= on a record containing the array: type Population (P, Q, R : Natural) is record Population_Data : array (1 .. Popsize) of Individual(P, Q, R); end record; I haven't tested this but I *think* it will work. -- Adam