diff --git a/content/courses/advanced-ada/parts/data_types/types_representation.rst b/content/courses/advanced-ada/parts/data_types/types_representation.rst index 961c60f10..710e9fb40 100644 --- a/content/courses/advanced-ada/parts/data_types/types_representation.rst +++ b/content/courses/advanced-ada/parts/data_types/types_representation.rst @@ -87,10 +87,12 @@ totally arbitrary values as well. For example: end Days; +.. _Adv_Ada_Data_Representation: + Data Representation ------------------- -This section provides a glimpse on attributes and aspects used for data +The following sections provide a glimpse on attributes and aspects used for data representation. They are usually used for embedded applications because of strict requirements that are often found there. Therefore, unless you have very specific requirements for your application, in most cases, you won't need @@ -105,10 +107,11 @@ course. - :arm22:`13.3 Operational and Representation Attributes <13-3>` - :arm22:`13.5.3 Bit Ordering <13-5-3>` + .. _Adv_Ada_Data_Representation_Sizes: Sizes -~~~~~ +----- Ada offers multiple attributes to retrieve the size of a type or an object: @@ -151,7 +154,7 @@ to better understand the differences among those attributes. Size attribute and aspect -^^^^^^^^^^^^^^^^^^^^^^^^^ +~~~~~~~~~~~~~~~~~~~~~~~~~ Let's start with a code example using the :ada:`Size` attribute: @@ -243,7 +246,7 @@ this: possibly do it! COMPILATION ERROR!" Component size -^^^^^^^^^^^^^^ +~~~~~~~~~~~~~~ Let's continue our discussion on sizes with an example that makes use of the :ada:`Component_Size` attribute: @@ -364,7 +367,7 @@ multiplication of 2\ :sup:`31` - 1 components (maximum length) by 8 bits .. _Adv_Ada_Storage_Size_Attribute: Storage size -^^^^^^^^^^^^ +~~~~~~~~~~~~ To complete our discussion on sizes, let's look at this example of storage sizes: @@ -550,8 +553,11 @@ want to see. For example, having an exception being raised when the allocated memory for this data type has reached its limit might allow the application to have enough memory to at least handle the exception gracefully. + +.. _Adv_Ada_Data_Representation_Alignment: + Alignment -~~~~~~~~~ +--------- For many algorithms, it's important to ensure that we're using the appropriate alignment. This can be done by using the :ada:`Alignment` attribute and the @@ -687,8 +693,11 @@ Note that you can also retrieve the alignment associated with a class using & Point_3D'Class'Alignment'Image); end Show_Class_Alignment; + +.. _Adv_Ada_Overlapping_Storage: + Overlapping Storage -~~~~~~~~~~~~~~~~~~~ +------------------- Algorithms can be designed to perform in-place or out-of-place processing. In other words, they can take advantage of the fact that input and output arrays @@ -835,8 +844,11 @@ procedure: obviously don't share any storage space |mdash|, so we can use out-of-place processing. + +.. _Adv_Ada_Packed_Representation: + Packed Representation -~~~~~~~~~~~~~~~~~~~~~ +--------------------- As we've seen previously, the minimum number of bits required to represent a data type might be less than the actual number of bits used to store an object @@ -1020,7 +1032,7 @@ We elaborate on the topic of converting between data representations in the section on :ref:`changing data representation `. Trade-offs -^^^^^^^^^^ +~~~~~~~~~~ As indicated previously, when we're using a packed representation (vs. using a standard *unpacked* representation), we're trading off speed of access for less