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: 11232c,59ec73856b699922 X-Google-Attributes: gid11232c,public X-Google-Thread: 1108a1,59ec73856b699922 X-Google-Attributes: gid1108a1,public X-Google-Thread: fdb77,5f529c91be2ac930 X-Google-Attributes: gidfdb77,public X-Google-Thread: 103376,583275b6950bf4e6 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-05-09 12:27:03 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: mcq95@earthlink.net (Marc A. Criley) Newsgroups: comp.lang.java.advocacy,comp.object,comp.lang.ada,misc.misc Subject: Re: Using Ada for device drivers? (Was: the Ada mandate, and why it collapsed and died) Date: 9 May 2003 12:27:03 -0700 Organization: http://groups.google.com/ Message-ID: <254c16a.0305091127.42ec7b21@posting.google.com> References: <9fa75d42.0304230424.10612b1a@posting.google.com> <416273D61ACF7FEF.82C1D1AC17296926.FF0BFD4934A03813@lp.airnews.net> <9fa75d42.0305010621.55e99deb@posting.google.com> <254c16a.0305011035.13133e8d@posting.google.com> <9fa75d42.0305011727.5eae0222@posting.google.com> <17cd177c.0305072114.24f04783@posting.google.com> <9fa75d42.0305090612.261d5a5c@posting.google.com> NNTP-Posting-Host: 12.158.183.115 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1052508423 2706 127.0.0.1 (9 May 2003 19:27:03 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 9 May 2003 19:27:03 GMT Xref: archiver1.google.com comp.lang.java.advocacy:63420 comp.object:63112 comp.lang.ada:37123 misc.misc:14051 Date: 2003-05-09T19:27:03+00:00 List-Id: softeng3456@netscape.net (soft-eng) wrote in message news:<9fa75d42.0305090612.261d5a5c@posting.google.com>... > Do you really need your own sub-range of integers > very often? Arrays with variable index ranges? > You must do a very different type of programming > from what I do. Several others have answered this as "Yes, yes, and Apparently"--as I would--but I'm not so sure about that last one. So here's a situation where I use integer subranges regularly: arrays! I virtually never declare an array where the bounds are explicitly specified as part of the _array_ definition. I always do something like this: Max_Items : constant := 100; type Item_Count is range 0 .. Max_Items; subtype Item_Index is Item_Count range 1 .. Item_Count'Last; type Item_Array is array(Item_Index) of Some_Type; Items : Item_Array; So of course I now have full range checking on my indexing and item counting, and reduce the risk of trying to index it with an "alien" index. By that I mean that if Items has been declared as Items : array(1..100) of Some_Type; It could be indexed by any of: Widget_Count : Integer; Population_Count : Integer; Item_Count_A : Integer; Item_Count_B : Integer; Item_Count_C : Integer; For none of which are there any constraints on the values they take, but all are legal array indexers given the latter Items definition. (And this is in effect what you get with C/C++ when it comes to arrays.) Obviously I've written a few extra lines of code for my array declaration, what with the three type definitions, but the ROI is that I've embedded lots of information into my code (which I can extract with Ada's attributes), plus I get range checking, count and index verification, and reduced the risk of indexing with the wrong index variable. Again, do I or anyone _need_ to do it this way? No, of course not, I can be very careful, or be a preternatually gifted programmer that rarely makes such mistakes, but the latter are rather rare, and don't you want them focusing their skills on bigger and better things than keeping array indices straight? Marc A. Criley