Skip to content

Commit

Permalink
Merge pull request #1169 from gusthoff/content/advanced_ada/review/ed…
Browse files Browse the repository at this point in the history
…itorial/types_representation/20250105

Editorial change: splitting section on data representation
  • Loading branch information
gusthoff authored Jan 6, 2025
2 parents 6bedfac + c45e554 commit d47dcbf
Showing 1 changed file with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:

Expand Down Expand Up @@ -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:

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1020,7 +1032,7 @@ We elaborate on the topic of converting between data representations in the
section on :ref:`changing data representation <Adv_Ada_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
Expand Down

0 comments on commit d47dcbf

Please sign in to comment.