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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f891f,9d58048b8113c00f X-Google-Attributes: gidf891f,public X-Google-Thread: 103376,2e71cf22768a124d X-Google-Attributes: gid103376,public X-Google-Thread: 1014db,9d58048b8113c00f X-Google-Attributes: gid1014db,public X-Google-Thread: 10cc59,9d58048b8113c00f X-Google-Attributes: gid10cc59,public From: Richard Riehle Subject: Re: next "big" language?? (disagree) Date: 1996/06/06 Message-ID: #1/1 X-Deja-AN: 158976352 references: <4p3nqb$k4a@btmpjg.god.bel.alcatel.be> <4p3nto$k4a@btmpjg.god.bel.alcatel.be> to: Ian Ward content-type: TEXT/PLAIN; charset=US-ASCII organization: National University, San Diego mime-version: 1.0 newsgroups: comp.lang.ada,comp.lang.pascal,comp.lang.c,comp.lang.misc Date: 1996-06-06T00:00:00+00:00 List-Id: On 5 Jun 1996, Ian Ward wrote: > On 5/6/95, in reply to Peter Hermann, who said > ">When I decide, as a programmer, that a peculiar type or > >variable may have a value in the range from 1 to 9, can you please > >explain me why it should be useful to assign a value of 10 or > >4711 or -1234?" > > Robin, from Australia raplied. > > "---Why, someone inevitably decides that the range is going > to be something different! Users are apt to change their minds. > Then someone has to go in and modify the program. Or, someone > overlooked a limit, and put in a limit one smaller than that > actually required. Again, someone has to go in and find where > that limit is, and change it." Good point. This is one of the very reasons why Ada works so well for this kind of thing, when programs are written correctly. In particular, when one takes advantage of the availability of attributes. Let's say that we establish a range of 1 through 10 for some type T1. Then we write a program using variables of that type. For example, we define the type T1, and an unconstrained array as follows: type T1 is range 1..10; type Vector is array(Positive range <>) of Float; Then we declare a variable of type Vector: Float_Set : Vector(T1'First..T1'Last); Some algorithm, elsewhere in the code can be written as: for I in Float_Set'Range loop ... end loop; As we separate the concerns of implementation, generalizing our algorithms with attributes and other useful Ada mechanisms, we discover that we can write those algorithms independently of explicit range information. This is only on example of the power of Ada. One could illustrate many more if necessary. Granted, if we abide by the rules of static binding, it is necessary to recompile the entire dependent set of compilation units when we change the ranges, but this is more of a mechanical excercise and has no impact on the underlying logic of our implementation. Software practitioners unfamiliar with Ada often make the mistake of believing that the restrictive nature of their favorite language carries over to Ada. That is why it is so much fun to see those practitioners become excited when they learn just how powerful this language really is. Richard Riehle