TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy


Options: Use Classic View

Use Monospaced Font
Show HTML Part by Default
Show All Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
"W. Wesley Groleau x4923" <[log in to unmask]>
Thu, 10 Dec 1998 12:01:50 -0500
text/plain (46 lines)
> nested procedures should sometimes
> be used when they are really macros, ....

By "really macros" do you mean something like the stuff below?

I have often made code much more readable by using nested procedures to
divide something into subtasks.  It is not "factoring common code" since
each is only called once.  They don't belong at package spec level because
no one else will (or should) call them.

Putting them at package body level offers what benefit?  Emulating a
language that can't nest procedures?  (I'd like to read the paper, but not
if I have to buy the proceedings.  Is it online?)

Web search with the word "nesting" gets mostly hits on ornithology and
genealogy.  :-) (Even if I add "Ada" and "Clarke")

procedure Trip is   -- example

   procedure Leave_For_Grandmas is -- could even be separate...
      Drive_North (Blocks => 4);
      Take_Onramp (Interstate => 95,
                   Direction  => North);
   end Leave_For_Grandmas;

   procedure Go_To_Grandmas is-- could even be separate...
      Avoid_Wolf;   -- sorry, couldn't resist
   end Go_To_Grandmas;

   procedure ... etc.

begin  -- Trip
   (Topics => (Manners, Fighting, Begging_For_Candy));
end Trip;