comp.lang.ada
 help / color / mirror / Atom feed
* Return statements and their scope - guideline
@ 2007-02-14 16:20 Maciej Sobczak
  2007-02-14 16:41 ` Jeffrey R. Carter
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Maciej Sobczak @ 2007-02-14 16:20 UTC (permalink / raw)


Hi,

I have found a coding guideline that allows return statements only in 
the outermost scope in the subprogram - which is supposed to avoid 
obscuring the control flow.

What is outermost scope in this context?

function F return Integer is
begin
   if Some_Condition then
      return 0;   -- (1)
   end if;
   -- ...
   declare
     X : Integer;
   begin
     -- ...
     return X;    -- (2)
   end;
   -- ...
   return 7;      -- (3)
end F;

Is (1) above in the outermost scope?
I understand that (2) is not (and is therefore discouraged) and (3) is 
definitely in the outermost scope, but (1) is not very obvious.

-- 
Maciej Sobczak : http://www.msobczak.com/
Programming    : http://www.msobczak.com/prog/



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

end of thread, other threads:[~2007-02-15  7:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-14 16:20 Return statements and their scope - guideline Maciej Sobczak
2007-02-14 16:41 ` Jeffrey R. Carter
2007-02-14 17:31   ` Adam Beneschan
2007-02-15  7:33     ` Maciej Sobczak
2007-02-15  7:37   ` Maciej Sobczak
2007-02-14 16:46 ` Adam Beneschan
2007-02-14 20:06 ` Robert A Duff

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