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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,1a6e940e9297b109 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,UTF8 Path: g2news1.google.com!postnews.google.com!j20g2000hsi.googlegroups.com!not-for-mail From: "framefritti@gmail.com" Newsgroups: comp.lang.ada Subject: Re: Curiosity about rage checking Date: Thu, 7 Feb 2008 02:36:01 -0800 (PST) Organization: http://groups.google.com Message-ID: References: <29e89783-8802-474e-b3c7-9721407ce42e@s13g2000prd.googlegroups.com> NNTP-Posting-Host: 158.110.28.116 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1202380562 22031 127.0.0.1 (7 Feb 2008 10:36:02 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 7 Feb 2008 10:36:02 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: j20g2000hsi.googlegroups.com; posting-host=158.110.28.116; posting-account=9fwclgkAAAD6oQ5usUYhee1l39geVY99 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 Galeon/1.2.11 (X11; Linux i686; U;) Gecko/20030708,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:19726 Date: 2008-02-07T02:36:01-08:00 List-Id: Jean-Pierre Rosen ha scritto: > framefritti@gmail.com a =EF=BF=BDcrit : > > [..] > > > > My question is: is an Ada compiler allowed to move the check outside > > the loop? > > This question is addressed in the (in)famous paragraph 11.6. If you > don't understand exactly what it says, don't worry, you are not alone... > > But the important issue is that compilers are unlikely to perform that > optimization. Why? Because optimization is a matter of improving what's > normally used. And any decent Ada programmer should write that loop as: > > for I in X'range loop... > > Where the optimization becomes trivial I agree, and that is what I usually do, but there are times when you want to loop over a limited part of X or not in the usual order (e.g., transposing a matrix stored (for whatever reason) as a one-dimensional array) > -- > --------------------------------------------------------- > J-P. Rosen (rosen@adalog.fr) > Visit Adalog's web site at http://www.adalog.fr