Ada 95 Quality and Style Guide Chapter 8

Chapter 8: Reusability - TOC - 8.2 ROBUSTNESS

8.2.5 Overloading in Generic Units

guideline

  • Be careful about overloading the names of subprograms exported by the same generic package.

  • example

    ------------------------------------------------------------------------
    generic
       type Item is limited private;
    package Input_Output is
       procedure Put (Value : in     Integer);
       procedure Put (Value : in     Item);
    end Input_Output;
    ------------------------------------------------------------------------
    

    rationale

    If the generic package shown in the example above is instantiated with Integer (or any subtype of Integer) as the actual type corresponding to generic formal Item, then the two Put procedures have identical interfaces, and all calls to Put are ambiguous. Therefore, this package cannot be used with type Integer. In such a case, it is better to give unambiguous names to all subprograms. See the Ada Reference Manual (1995, §12.3) for more information.


    < 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