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 Path: g2news1.google.com!postnews.google.com!l20g2000yqm.googlegroups.com!not-for-mail From: Phil Clayton Newsgroups: comp.lang.ada Subject: Re: initialize an array (1-D) at elaboration using an expression based on the index? Date: Sun, 24 Oct 2010 15:48:21 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <1f6bad81-e3d2-428b-a1a0-45acc7f96f68@m7g2000yqm.googlegroups.com> <9df4e5eb-fba7-4e8c-ba44-cd1ad4081d3b@26g2000yqv.googlegroups.com> NNTP-Posting-Host: 91.110.141.84 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1287960501 11138 127.0.0.1 (24 Oct 2010 22:48:21 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 24 Oct 2010 22:48:21 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: l20g2000yqm.googlegroups.com; posting-host=91.110.141.84; posting-account=v7gx3AoAAABfjb9m5b7l_Lt2KVEgQBIe User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.0.15) Gecko/2009102704 Fedora/3.0.15-1.fc10 Firefox/3.0.15,gzip(gfe) Xref: g2news1.google.com comp.lang.ada:14726 Date: 2010-10-24T15:48:21-07:00 List-Id: On Oct 24, 5:40=A0pm, Shark8 wrote: > Interesting. > It doesn't look like it would be very extensible into multidimensional > arrays though. > > Perhaps something like an 'Initialize attribute [on the type, not the > variables thereof] which would take an Access to Function returning > that type. It would have to be called only in the case of K : > Array_Type because K : Array_Type:=3D (Others =3D> <>) is providing an > initialization of the default value to all the elements [which is > unlikely to match the initialization's value]. > > However, it is the internals of the function which are interesting if > this route were taken. =A0The indexings need to be discrete types, > however they need not be numeric or even all the same type. This > results in the following being valid: > =A0 Type A_HighSchool_Letterjacket_Type is Array (Size, Color, > Character) of Byte; -- A jacket-maker's inventory for letter-jackets. > > So we can't have an "array" representing the indicies for use in the > initialization-function. > (ex: ---Invalid > =A0 For Index_1 in Index(1)'Range loop > =A0 =A0 For Index_2 in Index(2)'Range loop > =A0 =A0 =A0 For Index_3 in Index(3)'Range loop > =A0 =A0 =A0 =A0 -- do stuff for calculating the value stored; > =A0 =A0 =A0 end loop; > =A0 =A0 end loop; > =A0 end loop; > ) Good point. I think it is ok for multidimensional arrays given the right interpretation of a "for expression" though. In fact, it should probably be called a "for aggregate". It looked like Adam was suggesting that it would just be another case of array_aggregate (4.3.3) in the syntax. So a nested "for aggregate" would, presumably, work as a subaggregate allowing multidimensional arrays to handled. Another way to think about this is that (for I in T =3D> F(I)) would be equivalent to and interchangeable with the named aggregate (X1 =3D> F(X1), X2 =3D> F(X2), ...) where X1, X2, ... are the elements of subtype T. With that view, it seems a fairly simple extension to the language from a technical perspective. Phil