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,4215feeab2a8154a X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news3.google.com!feeder.news-service.com!club-internet.fr!feedme-small.clubint.net!nuzba.szn.dk!news.jacob-sparre.dk!pnx.dk!not-for-mail From: Jacob Sparre Andersen Newsgroups: comp.lang.ada Subject: Language checks (Was: C++0x and Threads - a poor relation to Ada's tasking model?) Date: 14 Aug 2009 13:24:09 +0200 Organization: Jacob Sparre Andersen Sender: sparre@jspa-nykredit Message-ID: <874osar63q.fsf_-_@jspa-nykredit.sparre-andersen.dk> 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> NNTP-Posting-Host: 95.209.235.157.bredband.3.dk Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: munin.nbi.dk 1250249115 27328 95.209.235.157 (14 Aug 2009 11:25:15 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Fri, 14 Aug 2009 11:25:15 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 Xref: g2news2.google.com comp.lang.ada:7771 Date: 2009-08-14T13:24:09+02:00 List-Id: Dmitry A. Kazakov wrote: > 1. These checks must be there, else the program is wrong > 2. The language is wrong not allowing programmer to design these checks > static [*] > > When it is neither 1 nor 2, then it is something which we can prove > to be OK in our program, while the compiler cannot. Is a normal > programmer that smart? Probably not. > ----------- > * 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. Greetings, Jacob -- �Later software patents have had a similar effect, they force us to stand on each other's toes instead of on each other's shoulders.� -- Per Abrahamsen