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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC 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!news2.google.com!news.glorb.com!feeder.news-service.com!feed.xsnews.nl!border-2.ams.xsnews.nl!border2.nntp.ams.giganews.com!nntp.giganews.com!newsfeed-fusi2.netcologne.de!news.netcologne.de!newsfeed-hp2.netcologne.de!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Curiosity about rage checking Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <29e89783-8802-474e-b3c7-9721407ce42e@s13g2000prd.googlegroups.com> Date: Thu, 7 Feb 2008 12:21:01 +0100 Message-ID: <1fo4kfkv5m8xt.uuhbb0mso1ik.dlg@40tude.net> NNTP-Posting-Date: 07 Feb 2008 12:21:01 CET NNTP-Posting-Host: bcc68d62.newsspool3.arcor-online.net X-Trace: DXC=cal0eV_a:LM74okIm;?DS@McF=Q^Z^V3H4Fo<]lROoRAgUcjd<3m<;B2l84:\?TkBI[6LHn;2LCVN7enW;^6ZC`DIXm65S@:3>OA;E726dPK]D X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:19727 Date: 2008-02-07T12:21:01+01:00 List-Id: On Thu, 7 Feb 2008 02:36:01 -0800 (PST), framefritti@gmail.com wrote: > Jean-Pierre Rosen ha scritto: > >> framefritti@gmail.com a �crit : >>> [..] >>> >>> 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) You still can follow that path: Assuming that X is array (Integer range <>) of something real (:-)): subtype Domain is Integer range X'Range; subtype Subdomain is Domain range Domain'First + 1..Domain'Last - 1; begin for I in Subdomain loop X (I) := 0.0; -- The compiler should know that I is from X'Range end loop; -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de