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.1 required=5.0 tests=BAYES_20,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!att!dptg!ulysses!ucbvax!WSMR-SIMTEL20.ARMY.MIL!AMXMC-SEL From: AMXMC-SEL@WSMR-SIMTEL20.ARMY.MIL (Mark Oestmann) Newsgroups: comp.lang.ada Subject: Re: Problems/Risks ... Message-ID: <12568231436.32.MOESTMANN@WSMR-SIMTEL20.ARMY.MIL> Date: 21 Feb 90 23:57:15 GMT Sender: usenet@ucbvax.BERKELEY.EDU Organization: The Internet List-Id: In Message-ID: <5432@crdgw1.crd.ge.com> Richard A Hammond writes: > What other programming language? Only one without any GOTO or restricted > GOTO (e.g. exit, break, ...). This leaves out Ada!!!!!! > > Similar bug in Ada: (Cut down for posting, but gives the flavor) > > procedure test is > MAX : constant := 10; > type t is array(positive range 1 .. MAX) of boolean; > NEW_ITEMS : t; > > begin > for N in 1 .. MAX loop > case ... > when ... => > if NEW_ITEMS(N) = FALSE then > -- some other useful work gets done here > exit; -- exits loop, not if! > end if; > when ... => > end case; > end loop; > end test; > > So, in the AT&T case using Ada we would have exited both the switch and the > loop rather than just the switch. Hardly an improvement! > > More generally, I find it distressing that the advocates of Ada are > failing to distinguish between language independent features and language > dependent features in assigning credit for software improvements. I agree, somewhat. Both Ada and C require a huge dose of software engineering and good coding practices to make them work properly. Good coding practices dictate that destination of the transfer of control should be explicitly specified. In Ada this may be done in any type of loop (The Ada 'exit' statement exits ONLY from a loop.) by naming the loop: TELEPHONE_LOOP: for Counter in Telephone_Type loop -- executable code if Some_Condition then -- executable code elsif Some_Other_Condition then -- executable code else exit TELEPHONE_LOOP; end if; -- executable code; end loop TELEPHONE_LOOP; The same thing could be done in C by giving a name to the loop or switch in a comment preceding the loop or switch. The name of this loop or switch would also appear in a comment following the 'break' statement. The only drawback would be that the intent of the programmer is not necessarily fulfilled by the compiler if there existed a innermore loop or switch. AS PERTAINS TO THE Ada 'GOTO': It is not needed. Our Software Engineering program is one year in length and has Ada as the core language. The students do not hear the word 'GOTO' as pertains to Ada until the day of graduation. My parting shot to them is, "By the way, Ada does have a 'GOTO'. Don't use it." Granted, the ability to foul up a program is available in Ada as well as in C or any other language. Naming exited loops (or switches) and never using 'GOTO's are two of many good coding practices that help eliminate software errors. Adherence to software engineering principles and good coding practices is the only solution to our problems. Mark Oestmann School of Engineering and Logistics Red River Army Depot Texarkana, TX 75507-5000 -------