From 3a2abf0430a7117b5f8f72861bbe7b71576aac85 Mon Sep 17 00:00:00 2001 From: gusthoff Date: Sat, 3 Aug 2024 17:03:36 +0200 Subject: [PATCH 1/3] Improving phrase about max. length of unbounded strings --- .../courses/intro-to-ada/chapters/standard_library_strings.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/content/courses/intro-to-ada/chapters/standard_library_strings.rst b/content/courses/intro-to-ada/chapters/standard_library_strings.rst index 1e3800039..a79b612a2 100644 --- a/content/courses/intro-to-ada/chapters/standard_library_strings.rst +++ b/content/courses/intro-to-ada/chapters/standard_library_strings.rst @@ -17,7 +17,8 @@ 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. The following sections present an overview of the different string types and common operations for string types. From 1441d1c59552978e34da825aff706a2c5c693c6a Mon Sep 17 00:00:00 2001 From: gusthoff Date: Sat, 3 Aug 2024 17:07:00 +0200 Subject: [PATCH 2/3] Adding admonition on bounded and unbounded strings --- .../chapters/standard_library_strings.rst | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/content/courses/intro-to-ada/chapters/standard_library_strings.rst b/content/courses/intro-to-ada/chapters/standard_library_strings.rst index a79b612a2..9833a1d64 100644 --- a/content/courses/intro-to-ada/chapters/standard_library_strings.rst +++ b/content/courses/intro-to-ada/chapters/standard_library_strings.rst @@ -20,6 +20,25 @@ text processing. Ada offers alternative approaches for these cases: 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 string, the + limit is :arm:`defined by the Reference Manual `: + + 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 `). + + 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. From c520acf17554acb1ddad18cb0c2c1d3692daa05e Mon Sep 17 00:00:00 2001 From: gusthoff Date: Sat, 3 Aug 2024 17:24:38 +0200 Subject: [PATCH 3/3] Editorial change: minor grammar fix --- .../courses/intro-to-ada/chapters/standard_library_strings.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/courses/intro-to-ada/chapters/standard_library_strings.rst b/content/courses/intro-to-ada/chapters/standard_library_strings.rst index 9833a1d64..68d7117a1 100644 --- a/content/courses/intro-to-ada/chapters/standard_library_strings.rst +++ b/content/courses/intro-to-ada/chapters/standard_library_strings.rst @@ -22,7 +22,7 @@ text processing. Ada offers alternative approaches for these cases: .. admonition:: For further reading... - Although we don't specify a maximum length for unbounded string, the + Although we don't specify a maximum length for unbounded strings, the limit is :arm:`defined by the Reference Manual `: An object of type :ada:`Unbounded_String` represents a :ada:`String`