comp.lang.ada
 help / color / mirror / Atom feed
* Re: Problems/Risks ...
@ 1990-02-21 23:57 Mark Oestmann
  1990-02-25 20:11 ` Problems/Risks David Kassover
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Oestmann @ 1990-02-21 23:57 UTC (permalink / raw)


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

-------

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1990-02-26 18:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1990-02-21 23:57 Problems/Risks Mark Oestmann
1990-02-25 20:11 ` Problems/Risks David Kassover
1990-02-25 21:12   ` Eliminating the GOTO William Thomas Wolfe, 2847 
1990-02-26 13:20   ` Problems/Risks John F Nixon
1990-02-26 18:32     ` Problems/Risks David Kassover

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox