Ada 95 Quality and Style Guide Chapter 7

Chapter 7: Portability - TOC - 7.6 REPRESENTATION CLAUSES AND IMPLEMENTATION-DEPENDENT FEATURES

7.6.1 Representation Clauses

guideline

  • Use algorithms that do not depend on the representation of the data and, therefore, do not need representation clauses.
  • Consider using representation clauses when accessing or defining interface data or when a specific representation is needed to implement a design.
  • Do not assume that sharing source files between programs guarantees the same representation of data types in those files.

  • rationale

    In many cases, it is easy to use representation clauses to implement an algorithm, even when it is not necessary. There is also a tendency to document the original programmer's assumptions about the representation for future reference. But there is no guarantee that another implementation will support the representation chosen. Unnecessary representation clauses also confuse porting or maintenance efforts, which must assume that the programmer depends on the documented representation.

    Interfaces to external systems and devices are the most common situations where a representation clause is needed. Uses of pragma Import and address clauses should be evaluated during design and porting to determine whether a representation clause is needed.

    Without representation clauses, the language does not require two compilations of an unchanged file to result in the same data representation. Things that can change the representation between compilations include:

    - A change in a file earlier in the compilation order
    - A change in the optimization strategy or level
    - A change in versions of the compiler
    - A change in actual compilers
    - A change in the availability of system resources

    Therefore, two independently linked programs or partitions should only share data that has their representations explicitly controlled.

    notes

    During a porting effort, all representation clauses can be evaluated as either design artifacts or specifications for accessing interface data that might change with a new implementation.


    < 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