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: 103376,5d489a63e16a038 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news1.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!news.in2p3.fr!in2p3.fr!oleane.net!oleane!hunter.axlog.fr!nobody From: Jean-Pierre Rosen Newsgroups: comp.lang.ada Subject: Re: loop variable Date: Tue, 30 Sep 2008 09:52:26 +0200 Organization: Adalog Message-ID: References: <48e0b042$0$26352$4d3efbfe@news.sover.net> NNTP-Posting-Host: mailhost.axlog.fr Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Trace: s1.news.oleane.net 1222756283 16964 195.25.228.57 (30 Sep 2008 06:31:23 GMT) X-Complaints-To: abuse@oleane.net NNTP-Posting-Date: Tue, 30 Sep 2008 06:31:23 +0000 (UTC) User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) In-Reply-To: <48e0b042$0$26352$4d3efbfe@news.sover.net> Xref: g2news1.google.com comp.lang.ada:2154 Date: 2008-09-30T09:52:26+02:00 List-Id: Peter C. Chapin a �crit : > jedivaughn wrote: > >> What data_type is a loop variable >> as an example >> for i in 1..10 >> what data type is i? > > The subtype of a loop variable is the subtype used to define the loop's > range. Something like '1..10' is shorthand for 'Integer range 1..10' and > so in your example I has type Integer. > > However, I echo the comments Georg Bauhaus made in his post: be careful > with conversions. They often (not always) mean you haven't defined your > types properly or that you haven't declared your variables with the most > appropriate types. > To concur with that: The declaration of a loop control variable is the only case in Ada where you can define an object without giving (explicitely) its type in the same declaration - and it's unfortunate. Remember that you are always allowed (although not required) to specify the type explicitely: for I in My_Integer_Type range 1 .. 10 loop Of course, there is a rule in AdaControl to check for loops that don't follow this advice ;-) -- --------------------------------------------------------- J-P. Rosen (rosen@adalog.fr) Visit Adalog's web site at http://www.adalog.fr