Ada 95 Quality and Style Guide Chapter 5

Chapter 5: Programming Practices - TOC - 5.7 VISIBILITY

5.7.3 Overloaded Subprograms

guideline

  • Limit overloading to widely used subprograms that perform similar actions on arguments of different types (Nissen and Wallis 1984).

  • example
    function Sin (Angles : in     Matrix_Of_Radians) return Matrix;
    function Sin (Angles : in     Vector_Of_Radians) return Vector;
    function Sin (Angle  : in     Radians)           return Small_Real;
    function Sin (Angle  : in     Degrees)           return Small_Real;
    

    rationale

    Excessive overloading can be confusing to maintainers (Nissen and Wallis 1984, 65). There is also the danger of hiding declarations if overloading becomes habitual. Attempts to overload an operation may actually hide the original operation if the parameter profile is not distinct. From that point on, it is not clear whether invoking the new operation is what the programmer intended or whether the programmer intended to invoke the hidden operation and accidentally hid it.

    notes

    This guideline does not prohibit subprograms with identical names declared in different packages.


    < 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