comp.lang.ada
 help / color / mirror / Atom feed
From: Marin David Condic <condicma@bogon.pwfl.com>
Subject: Re: Self-referential types
Date: 1999/10/15
Date: 1999-10-15T00:00:00+00:00	[thread overview]
Message-ID: <38078775.73450564@pwfl.com> (raw)
In-Reply-To: 38077EB3.E6911567@mitre.org

"Robert I. Eachus" wrote:

>    AFIAK, it is almost always poor engineering to declare procedures
> within other procedures in Ada. The chief exception is recursive descent
> parsers, and even in that case there are good arguments for using
> unnested procedures.  Also there are cases where you want to break a
> procedure into subunits for implementation reasons:
>

This debate has been around before and a case has been made on the other
side. Similar to the Cobol "perform", nested procedures give you a way of
grouping blobs of code under some sort of descriptive name which helps
clarify the main body of the code - especially where the main body of the
code might otherwise become too deeply nested in control sturctures. For
example:

procedure Process_Payroll is
    procedure Read_In_Transaction_Trapping_Device_Errors (
        Trans : out Trans_Type) is
    begin
        --Use Your Imagination
    end Read_In_Transaction_Trapping_Device_Errors ;
    function Transaction_Successfully_Read return Boolean is
    begin
        --More of the same...
    end Transaction_Successfully_Read ;
    procedure Edit_Transaction_For_Keypunch_Errors (
        Trans : in out Trans_Type) is
    begin
        --Fill in the blanks.
    end Edit_Transaction_For_Keypunch_Errors ;
begin
    --blahblahblah

    while (not End_Of_File (Trans_File)) loop
        Read_In_Transaction_Trapping_Device_Errors (Trans) ;
        if (Transaction_Successfully_Read) then
            Edit_Transaction_For_Keypunch_Errors (Trans) ;
        end if ;
        --yadayadayada
    end loop ;

    --blahblahblah
end Process_Payroll ;

You can always export the nested procedures by making them "is separate" or
just stand-alone procedures brought in with a "with" clause, but if the code
volume is not too large and the access to common data is high, I'd prefer to
see it local to the same file from which it is called. I wouldn't think of
that as bad software engineering or bad style. It all depends on if it is
helping you clarify what you are doing and is not being badly overused.

Obviously, after "a certain size" you probably want these things in separate
units for configuration management, reusability and other concerns. What is
the threshold? I'd say "As many lines as you can read while holding your
breath." :-)

MDC
--
Marin David Condic
Real Time & Embedded Systems, Propulsion Systems Analysis
United Technologies, Pratt & Whitney, Large Military Engines
M/S 731-95, P.O.B. 109600, West Palm Beach, FL, 33410-9600
***To reply, remove "bogon" from the domain name.***

Visit my web page at: http://www.mcondic.com/






  reply	other threads:[~1999-10-15  0:00 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <7ttb4a$8mq$1@nnrp1.deja.com>
     [not found] ` <3802597B.9205AEE8@averstar.com>
1999-10-12  0:00   ` Self-referential types Ted Dennison
1999-10-12  0:00     ` Matthew Heaney
1999-10-13  0:00       ` Ted Dennison
1999-10-12  0:00 ` Robert A Duff
1999-10-12  0:00 ` Vladimir Olensky
1999-10-12  0:00   ` Matthew Heaney
1999-10-12  0:00     ` Ted Dennison
1999-10-12  0:00       ` Matthew Heaney
1999-10-12  0:00     ` Robert I. Eachus
1999-10-12  0:00       ` Matthew Heaney
1999-10-13  0:00         ` Ted Dennison
1999-10-13  0:00           ` Matthew Heaney
1999-10-13  0:00         ` Vladimir Olensky
1999-10-13  0:00           ` Vladimir Olensky
1999-10-18  0:00           ` Robert Dewar
1999-10-18  0:00             ` Laurent Guerby
1999-10-18  0:00             ` Vladimir Olensky
1999-10-13  0:00         ` Robert I. Eachus
1999-10-13  0:00           ` Brian Rogoff
1999-10-15  0:00             ` Robert I. Eachus
1999-10-15  0:00               ` Marin David Condic [this message]
1999-10-15  0:00                 ` Robert I. Eachus
1999-10-18  0:00                   ` Robert Dewar
1999-10-19  0:00                     ` Robert I. Eachus
1999-10-18  0:00               ` Robert Dewar
1999-10-18  0:00                 ` Brian Rogoff
1999-10-18  0:00                 ` Ed Falis
1999-10-19  0:00                   ` Robert Dewar
     [not found]               ` <7u86su$o5v$1@nntp8.atl.mindspring.net>
1999-10-18  0:00                 ` Robert I. Eachus
1999-10-22  0:00                   ` Richard D Riehle
1999-10-22  0:00                     ` Robert I. Eachus
     [not found]               ` <slrn80fl9f.68j.aidan@skinner.demon.co.uk>
1999-10-19  0:00                 ` Wes Groleau
1999-10-21  0:00                   ` Robert Dewar
1999-10-21  0:00                     ` Jean-Pierre Rosen
1999-10-21  0:00                       ` Robert Dewar
1999-10-21  0:00                     ` Comments (was: Self-referential types) Wes Groleau
1999-10-21  0:00                       ` Ehud Lamm
1999-10-22  0:00                         ` Ted Dennison
1999-10-23  0:00                           ` Ehud Lamm
1999-10-23  0:00                         ` Robert Dewar
1999-10-23  0:00                           ` Ehud Lamm
1999-10-23  0:00                             ` Comments Georg Bauhaus
1999-10-24  0:00                               ` Comments Ehud Lamm
1999-10-26  0:00                                 ` Comments Robert I. Eachus
1999-10-28  0:00                                   ` Comments Jerry van Dijk
1999-10-28  0:00                                     ` Comments Ted Dennison
1999-10-25  0:00                             ` Comments (was: Self-referential types) Wes Groleau
1999-10-23  0:00                       ` M.
     [not found]                       ` <Pine.A41.3.96-heb-2.07.991021191504.30582K-100000@pluto.mscc.huji. <381477c9.e1388ff3@ftw.rsc.raytheon.com>
1999-10-25  0:00                         ` Larry Kilgallen
1999-10-21  0:00                     ` Self-referential types Larry Kilgallen
1999-10-22  0:00                     ` Richard D Riehle
1999-10-23  0:00                       ` Robert A Duff
1999-10-23  0:00                         ` Richard D Riehle
1999-10-24  0:00                       ` Michel DELARCHE
1999-10-12  0:00     ` news.oxy.com
1999-10-12  0:00       ` Ted Dennison
1999-10-12  0:00         ` Stanley R. Allen
1999-10-13  0:00           ` Ted Dennison
1999-10-13  0:00         ` Vladimir Olensky
1999-10-14  0:00         ` Multiple Inheritance in Ada 95 [was Re: Self-referential types] Tucker Taft
1999-10-12  0:00       ` Self-referential types Matthew Heaney
1999-10-12  0:00     ` Richard D Riehle
replies disabled

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