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.66.136.74 with SMTP id py10mr2904142pab.20.1370308142590; Mon, 03 Jun 2013 18:09:02 -0700 (PDT) X-Received: by 10.50.3.74 with SMTP id a10mr57813iga.2.1370308142273; Mon, 03 Jun 2013 18:09:02 -0700 (PDT) Path: border1.nntp.dca3.giganews.com!border2.nntp.dca3.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!oz11no1132410pbb.0!news-out.google.com!bp1ni149pbd.1!nntp.google.com!ch1no555566qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 3 Jun 2013 18:09:01 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=69.20.190.126; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 69.20.190.126 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <55016aa4-4d69-4fd9-a2c9-a7eb7d3b00c5@googlegroups.com> Subject: Possible for Ada 2020: "Cursors" for Arrays From: Shark8 Injection-Date: Tue, 04 Jun 2013 01:09:02 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Original-Bytes: 2831 Xref: number.nntp.dca.giganews.com comp.lang.ada:181792 Date: 2013-06-03T18:09:01-07:00 List-Id: In a few threads a few people have expressed a desire to be able to initial= ize Arrays based on some formula usually including the indices. In order to= do this we need some sort of "cursor"-type/attribute. So, let us propose a cursor-attribute so that some array type, T1, defined = as type T1 is Array( 1..10 ) of Integer; could have a variable initialized as follows: V1 : T1:=3D (others =3D> T1'Cursor'Index) resulting in V1 getting (1,2,3,4,5,6,7,8,9,10); This doesn't scale to unconstrained arrays, however because given type T2 is Array( Positive Range <>) of Integer V2 : T2 :=3D (others =3D> others =3D> T1'Cursor'Index) becomes ambiguous/indeterminate [lacking any constraints to determine the c= orrect size] -- this could be ameliorated by requiring explicit bounds and = throwing a compiler error. Taking a page from the 'Length attribute we could make the attribute take a= n optional parameter indicating which of the indices we are referring to. -- completely forced example. Type CBT is Array(1..8,'A'..'H') of Piece; -- Transforms (1,A) to 1, (1,B) to 9, [...], (8,H) to 64 Chess_Board_Transform : CBT :=3D=20 (others =3D> 8*(Character'Pos(CBT'Cursor(2))-Character'Pos'A') + CBT'C= ursor(1) ); Note that because we know the types for the indices we should be able to us= e the cursor as that type for that index... This would also be a good place= for implementation of a 'Type attribute, as matching the 'cursor' to that = particular index would entail interrogating the previously known definition= for the proper type anyway. My question: does this look reasonable, or is it just superfluous?