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,5f5a48f21d7f7525 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!newsfeed.straub-nv.de!noris.net!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Wed, 23 Jun 2010 14:24:35 +0200 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.10) Gecko/20100512 Thunderbird/3.0.5 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Inferring array index type from array object References: <6b20ed09-efc1-4df7-90f9-5e141482e8d0@d37g2000yqm.googlegroups.com> <1305oqccr1h2t$.x33x4oxwd84d$.dlg@40tude.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <4c21fd04$0$6769$9b4e6d93@newsspool3.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 23 Jun 2010 14:24:36 CEST NNTP-Posting-Host: c9f8de25.newsspool3.arcor-online.net X-Trace: DXC=acNO]JB2@?3n`gW2MTm]<3McF=Q^Z^V384Fo<]lROoR18kF:Lh>_cHTX3j=:ZNOE@[GNo? X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:11885 Date: 2010-06-23T14:24:36+02:00 List-Id: On 23.06.10 11:03, J-P. Rosen wrote: >>> 2. Is it possible to declare the index variable without hardcoding the >>> index type (that is, to infer it from the array object)? >> > There is no point in doing this, since the type of the array /is/ > hardcoded anyway. You could allow the same "simplification" as for > loops, but as mentionned above, I prefer the other way round: always > explicitely give the type name. Is the required name somehow related to why the Ada.Container generics do not re-export the formal types? But anyway, without Dmitry's abstractions, a partial solution should work along these lines, I think, generic type Index_Type is (<>); type Component_Type is private; package GA is type Array_Type is array (Index_Type range <>) of Component_Type; generic with function "+" (Left, Right: Component_Type) return Component_Type is <>; Zero: in Component_Type; package Algorithms is function Sum (A: Array_Type) return Component_Type ; end Algorithms; end GA;