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: a07f3367d7,4215feeab2a8154a X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!news.glorb.com!news.musoftware.de!wum.musoftware.de!newsfeed.straub-nv.de!noris.net!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Language checks (Was: C++0x and Threads - a poor relation to Ada's tasking model?) Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <7q2385104kihs87d79p8kfphuoki6r01vq@4ax.com> <7961a91c-a5af-40e2-bbc0-6bf69a98176d@z31g2000yqd.googlegroups.com> <362f621e-a01c-4772-ba02-4e18e9962188@j19g2000vbp.googlegroups.com> <128d63da-361f-4e33-be5e-e06bdc71e39f@r34g2000vba.googlegroups.com> <6d23274b-d649-4a83-a6f1-6d1e9c4c3998@d34g2000vbm.googlegroups.com> <4A83D107.2020407@obry.net> <196q25f7ntf6a$.tj10ulon3mmt.dlg@40tude.net> <4A83F9C2.3000700@obry.net> <1376nmezwawim.1mqgiaglsrvwe.dlg@40tude.net> <874osar63q.fsf_-_@jspa-nykredit.sparre-andersen.dk> Date: Fri, 14 Aug 2009 14:01:16 +0200 Message-ID: <5teik046uoaz.dust9cbmbaxl.dlg@40tude.net> NNTP-Posting-Date: 14 Aug 2009 14:00:43 CEST NNTP-Posting-Host: b75d2b58.newsspool2.arcor-online.net X-Trace: DXC=462CkE7I\1gPKPPVf;4hUjA9EHlD;3Ycb4Fo<]lROoRa^YC2XCjHcbi2X?Mig[YN7lDNcfSJ;bb[eFCTGGVUmh?dLK[5LiR>kgbXA3\c32eNof X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:7772 Date: 2009-08-14T14:00:43+02:00 List-Id: On 14 Aug 2009 13:24:09 +0200, Jacob Sparre Andersen wrote: > Dmitry A. Kazakov wrote: > >> * Example in Ada. If you wanted to iterate two arrays at once, you could >> not eliminate index checks of one of them: >> >> for I in A'Range loop >> ... A (I) + B (I + B'First - A'First) ... >> -- No way to eliminate B index check >> end loop; > > In your example we don't know if the index check on B is needed. An > alternative: > > if B'Length >= A'Length then > for I in A'Range loop > ... A (I) + B (I + B'First - A'First) ... > end loop; > else > ... > end if; > > Here a compiler should be able to figure out statically that there is > no need for an index check on B in the loob. I would prefer something more universal and binding than a compiler with AI. For example: declare B_View : array (Index range A'Range) of Element renames B; begin for I in A'Range loop ... A (I) + B_View (I) ... end loop; renaming raises Constraint_Error if something goes wrong. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de