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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b0d68c502c0ae6 X-Google-Attributes: gid103376,public From: kilgallen@eisner.decus.org (Larry Kilgallen) Subject: Re: Printing Enum Variable Re: Linux World Date: 1999/03/09 Message-ID: <1999Mar9.131659.1@eisner>#1/1 X-Deja-AN: 453061288 X-Nntp-Posting-Host: eisner.decus.org References: <7bfc2n$jl9@dfw-ixnews5.ix.netcom.com> <7bhh26$r7c$1@remarQ.com> <36DCAC1F.430E2C5E@aasaa.ofe.org> <7bk4v8$kl8$1@remarQ.com> <36DDA761.7B4E8099@aasaa.ofe.org> <7bkrmm$ao1$1@nnrp1.dejanews.com> <36DE0007.5236CEA2@aasaa.ofe.org> <7bmmu2$n0h@news1.newsguy.com> <7btj81$j0d$1@remarQ.com> <1999Mar7.074102.1@eisner> <7bva62$kgm$1@remarQ.com> <7c0knr$v5$1@nnrp1.dejanews.com> <7c1833$2n@sjx-ixn6.ix.netcom.com> <7c3lft$t10$1@remarQ.com> X-Trace: news.decus.org 921003424 13420 KILGALLEN [192.67.173.2] Organization: LJK Software Reply-To: Kilgallen@eisner.decus.org.nospam Newsgroups: comp.lang.ada Date: 1999-03-09T00:00:00+00:00 List-Id: In article <7c3lft$t10$1@remarQ.com>, "Michael Young" writes: > Richard D Riehle wrote in message > news:7c1833$2n@sjx-ixn6.ix.netcom.com... >> In the end, it is not a matter of whether we can code the same thing >> in one language that we can code in another. It is a matter of how >> that same thing is expressed. It is not a matter of which syntax is >> more "natural"; not a matter of whether we do or do not have >> "distinguished receivers"; not a matter of how easy it is to code >> a particular set of ideas. Expressibility, in Ada, is a matter of >> creating reliable, maintainable applications in which human life >> and safety are at risk. For large, safety-critical software, >> whether that expressibility consistently represents (even demands) >> a model for reliability, dependability and safety. This defines the >> charter for Ada. > > How does Ada accomplish this? What is the language's role in ensuring > correctness? The role of the language is that those concerns permeate the design of the language. For instance, the enumerated types discussed earlier allow me to create a variable of type Traffic_Light_Color, knowing that the only values that can be assigned to it are Red, Yellow and Green. Furthermore, I know it cannot mistakenly get intermixed with values for a coworker's type Political_Orientation which has values Red and Freedom_Loving_Capitalist. That general idea is available in Pascal and other languages, but Ada takes it a bit further and allows me to iterate from the start (Traffic_Light_Color'first) to the end (Traffic_Light_Color'last) without specifically naming the values and thus making me immune to someone tacking on a new value at the end (or the beginning). You can readily come up with an example where one would _not_ want to use those capabilities, but in my experience I want them more often than not. When the answer is "not", I don't use them. And if it was not obvious, I have to really go out of my way to assign the value "7" to one of those variables. If that really is a valid traffic light color in Elbonia, then good programmers will enhance the original declaration to make "Seven" the fourth possiblity, thus letting the type system enforce the interface to the outside world. That is just a small part of the language which has safety elements built in. Ada is not unique in all its elements, but it is rather thorough in safety features. > With C's evils aside, I would guess the single largest problem for > inexperienced C++ programmers is understanding the lifetime of objects, > particularly temporaries used in implicit type conversions. However, the rules > for instantiation and destruction are very simple, and are easily expressed in > short, understandable sentences. Further, there are simple mechanisms to > prevent implicit construction of types where this is not appropriate. The > reason they exist, in spite of the acknowledged problems, is they are useful > in expressing the design intent (bringing this discussion back on track). They > are problems for inexperienced programmers, but extremely powerful when used > appropriately. In general, Ada tends toward compilation errors for those who have not understood the rules. That includes experts who have temporarily forgot while working on something Important, as well as students whose first reaction is to try it themselves rather than asking for their homework answers on comp.lang.ada. :-) Larry Kilgallen