Ada Programming/Pragmas/Pack:3

Exact data representation

edit

It is important to realize that pragma Pack must not be used to specify the exact representation of a data type, but to help the compiler to improve the efficiency of the generated code.[1] The compiler is free to ignore the pragma, therefore if a specific representation of a type is required, representation clauses should be used instead (record representation clauses, and/or attributes 'Size or 'Component_Size).

Bit-wise operations

edit

Although in Ada 83 packed boolean arrays were used for bit-wise operations,[2] since Ada 95 modular types are more adequate for these operations.[3] The argument may be weighed against the advantages of named Boolean array indexes such as Traffic_Lights'(Red => True, others => False), depending on use case.

  1. Adam Beneschan (2008-01-09). "Pragma Pack vs. Convention C, portability issue?". comp.lang.ada. (Web link). Retrieved on 2008-05-27.
  2. Software Productivity Consortium (October 1995). Ada 95 Quality and Style Guide, "10.5.7 Packed Boolean Array Shifts"
  3. Software Productivity Consortium (October 1995). Ada 95 Quality and Style Guide, "10.6.3 Bit Operations on Modular Types"