Ada 95 Quality and Style Guide Chapter 5

Chapter 5: Programming Practices - TOC - 5.1 OPTIONAL PARTS OF THE SYNTAX

5.1.4 Naming End Statements

guideline

  • Include the defining program unit name at the end of a package specification and body.
  • Include the defining identifier at the end of a task specification and body.
  • Include the entry identifier at the end of an acceptstatement.
  • Include the designator at the end of a subprogram body.
  • Include the defining identifier at the end of a protected unit declaration.

  • example
    ------------------------------------------------------------------------
    package Autopilot is
       function Is_Engaged return Boolean;
       procedure Engage;
       procedure Disengage;
    end Autopilot;
    ------------------------------------------------------------------------
    package body Autopilot is
       ...
       ---------------------------------------------------------------------
       task Course_Monitor is
          entry Reset (Engage : in     Boolean);
       end Course_Monitor;
       ---------------------------------------------------------------------
       function Is_Engaged return Boolean is
       ...
       end Is_Engaged;
       ---------------------------------------------------------------------
       procedure Engage is
       ...
       end Engage;
       ---------------------------------------------------------------------
       procedure Disengage is
       ...
       end Disengage;
       ---------------------------------------------------------------------
       task body Course_Monitor is
       ...
             accept Reset (Engage : in     Boolean) do
                ...
             end Reset;
       ...
       end Course_Monitor;
       ---------------------------------------------------------------------
    end Autopilot;
    ------------------------------------------------------------------------
    

    rationale

    Repeating names on the end of these compound statements ensures consistency throughout the code. In addition, the named end provides a reference for the reader if the unit spans a page or screen boundary or if it contains a nested unit.


    < Previous Page Search Contents Index Next Page >
    1 2 3 4 5 6 7 8 9 10 11
    TOC TOC TOC TOC TOC TOC TOC TOC TOC TOC TOC
    Appendix References Bibliography