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: 103376,478f58950f0bbbd2,start X-Google-Attributes: gid103376,public From: mike@zin.world.com Subject: A note on Ada subtyping Date: 1999/02/22 Message-ID: <7asf3h$9gm@drn.newsguy.com>#1/1 X-Deja-AN: 447228092 Organization: Newsguy News Service [http://www.newsguy.com] Newsgroups: comp.lang.ada Date: 1999-02-22T00:00:00+00:00 List-Id: As I am learning Ada (I use the GNAT compiler, an excellent compiler btw), I am more impressed with it. This is one simple example, where Ada helped me find a bug in my logic that I would not been able to find as easily if I was using C or C++ or even Java. I needed a variable, that logically could not take in values over some range, say n..m, becuase this is the nature of the problem was. So I defined this variable to be of of this type. (where in C/C++/Java, I would simply have made it an 'int' or a 'short' as almost eveyone else would have), giving the variable a much larger range that is really needed. During running of the program, the Ada run-time generated a contraint error exception as soon the program tried to assign a value to this variable outside this range. This quickly lead me to see where my logic error was, and I fixed it. This is an excelllent language. By using variables with restricted ranges and values, as in this case, Ada helped me find a prblem in my logic! Ada is giving me the power to write a more tight code thanks to the ability to easily define types as required by the problem domain. I know in the other languages, I would have missed this logic error, or at least it would have taken longer to find it. Makes me wonder, why isn't the whole world programming in Ada? Mike.