Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving introductory paragraph on unbounded strings #1084

Merged
merged 3 commits into from
Aug 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,27 @@ text processing. Ada offers alternative approaches for these cases:

- *Unbounded strings*: similar to bounded strings, unbounded strings can
contain strings of varied length. However, in addition to that, they don't
have a maximum length. In this sense, they are very flexible.
require a maximum length to be specified at the declaration of a string. In
this sense, they are very flexible.

.. admonition:: For further reading...

Although we don't specify a maximum length for unbounded strings, the
limit is :arm:`defined by the Reference Manual <A-4-5>`:

An object of type :ada:`Unbounded_String` represents a :ada:`String`
whose low bound is 1 and whose length can vary conceptually between 0
and :ada:`Natural'Last`.

Therefore, the implicit maximum length is :ada:`Natural'Last`. In
contrast, bounded strings have an explicit maximum length that is specified
when the :ada:`Generic_Bounded_Length` package is instantiated (as we'll
see :ref:`later on <Intro_Ada_Bounded_Strings>`).

Another difference between bounded and unbounded strings is the strategy
that is used by the compiler to allocate memory for those strings. When
using GNAT, bounded strings are allocated on the stack, while unbounded
strings are allocated on the heap.

The following sections present an overview of the different string types and
common operations for string types.
Expand Down
Loading