Critical packing means to allow packing according to the actual length of bits used. For example:
type x = 0..6;
Can be kept in 3 bits, so that's two values per byte, 5 values per 16 bit word, etc. It only matters in arrays and records.
Why? Critical packing both saves space, but more importantly allows the specification of arbitrary formats. For example the IEEE floating point format can be represented with critical packing. Its equivalent to the "bit specification" in C of struct fields.
A commonly used example of why critical packing makes sense is an array of boolean, which can take 1/8 of the space when critical packing is used.
Implementation
Critical packing is done by shifting, masking and or'ing fields. It's an old issue in Pascal. The original CDC6000 machine had to have packing because there was no byte access on the machine, just 60 bit words, so packing arrays and records was a normal procedure.
Critical packing is enabled and disabled by option, and this is one of the few places where changing options in the middle of the source makes sense.
Critical packing means to allow packing according to the actual length of bits used. For example:
type x = 0..6;
Can be kept in 3 bits, so that's two values per byte, 5 values per 16 bit word, etc. It only matters in arrays and records.
Why? Critical packing both saves space, but more importantly allows the specification of arbitrary formats. For example the IEEE floating point format can be represented with critical packing. Its equivalent to the "bit specification" in C of struct fields.
A commonly used example of why critical packing makes sense is an array of boolean, which can take 1/8 of the space when critical packing is used.
Implementation
Critical packing is done by shifting, masking and or'ing fields. It's an old issue in Pascal. The original CDC6000 machine had to have packing because there was no byte access on the machine, just 60 bit words, so packing arrays and records was a normal procedure.
Critical packing is enabled and disabled by option, and this is one of the few places where changing options in the middle of the source makes sense.