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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fdb77,5f529c91be2ac930 X-Google-Attributes: gidfdb77,public X-Google-Thread: f43e6,899fc98b2883af4a X-Google-Attributes: gidf43e6,public X-Google-Thread: 11232c,59ec73856b699922 X-Google-Attributes: gid11232c,public X-Google-Thread: 1108a1,59ec73856b699922 X-Google-Attributes: gid1108a1,public X-Google-Thread: 103376,583275b6950bf4e6 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-05-20 00:52:24 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!news.teledanmark.no!news.equant.no!uninett.no!dax.net!juliett.dax.net!not-for-mail Newsgroups: comp.lang.java.advocacy,comp.object,comp.lang.ada,misc.misc,comp.software-eng Subject: Re: Quality systems (Was: Using Ada for device drivers? (Was: the Ada mandate, and why it collapsed and died)) References: <9fa75d42.0304230424.10612b1a@posting.google.com> <9fa75d42.0305091549.48b9c5d9@posting.google.com> <7507f79d.0305121629.5b8b7369@posting.google.com> <9fa75d42.0305130543.60381450@posting.google.com> <254c16a.0305140549.3a87281b@posting.google.com> <9fa75d42.0305141747.5680c577@posting.google.com> <254c16a.0305160425.3bb89749@posting.google.com> <1053091306.979352@master.nyc.kbcfp.com> <7vaddj8k3d.fsf@vlinux.voxelvision.no> <7v65o78gtv.fsf@vlinux.voxelvision.no> <1053352870.115958@master.nyc.kbcfp.com> From: Ole-Hjalmar Kristensen Message-ID: <7v1xyu838x.fsf@vlinux.voxelvision.no> User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 20 May 2003 07:51:49 GMT NNTP-Posting-Host: 193.216.12.150 X-Complaints-To: abuse@tele2.no X-Trace: juliett.dax.net 1053417109 193.216.12.150 (Tue, 20 May 2003 09:51:49 MET DST) NNTP-Posting-Date: Tue, 20 May 2003 09:51:49 MET DST Organization: Tele2 Norway AS Public Access Xref: archiver1.google.com comp.lang.java.advocacy:64241 comp.object:63739 comp.lang.ada:37551 misc.misc:14308 comp.software-eng:19311 Date: 2003-05-20T07:51:49+00:00 List-Id: Hyman Rosen writes: > Ole-Hjalmar Kristensen wrote: > > A small typo, and the loop will probably not do what you want. > > I imagine that this is true of every programming language > ever invented. > Sure, but the probability that the compiler will complain about typos in the control part of an Ada for loop is higher than in the C for loop. > > What stops someone from modifying i inside the loop? > > Nothing. > But the Ada compiler will stop you if you try to change the loop parameter inside the loop. > > Also, begin() and end() only applies to STL type containers, not to > > plain arrays. > > Godd C++ programmers don't use plain arrays. Remember, C++ isn't > Ada, where arrays are convenient to use :-) And if you insist, > Yes, I know. But when you've got a few hundred thousand lines of legacy C++ code to maintain, like me, you are bound to see some plain arrays. > template > T *begin(T (&array)[N]) { return array; } > template > T *end(T (&array)[N]) { return array + N; } > template > char (&sizer(T (&)[N]))[N]; > > Now if you have an array A, begin(A) and end(A) will give you > pointers to the beginning and end suitable for use as STL > iterators. And sizeof(sizer(A)) will give you its number of > elements as a compile-time static expression. You will get > compile-time errors if you try to apply them to pointers > instead of arrays, eliminating a common source of C errors. > Neat trick. Templates are fun. -- Ole-Hj. Kristensen ****************************************************************************** * You cannot consistently believe this sentence. ******************************************************************************