Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ of control in any of the examples, the output may be interspersed.
[Ada]

.. code:: ada run_button ada project=Courses.Ada_For_Embedded_C_Dev.Concurrency.My_Task
:class: ada-run-expect-variable-output

with Ada.Text_IO; use Ada.Text_IO;

Expand Down Expand Up @@ -105,6 +106,7 @@ the underlying implementation of the task scheduling algorithm.
[Ada]

.. code:: ada run_button project=Courses.Ada_For_Embedded_C_Dev.Concurrency.My_Task_Type
:class: ada-run-expect-variable-output

package My_Tasks is

Expand Down Expand Up @@ -141,6 +143,7 @@ and terminates when its work is completed.
[Ada]

.. code:: ada run_button project=Courses.Ada_For_Embedded_C_Dev.Concurrency.My_Task_Type
:class: ada-run-expect-variable-output

with My_Tasks; use My_Tasks;

Expand All @@ -161,6 +164,7 @@ data and coordinate execution. Let's consider the following example:
[Ada]

.. code:: ada run_button project=Courses.Ada_For_Embedded_C_Dev.Concurrency.Rendezvous
:class: ada-run-expect-variable-output

with Ada.Text_IO; use Ada.Text_IO;

Expand Down Expand Up @@ -199,6 +203,7 @@ and executes some code:
[Ada]

.. code:: ada run_button project=Courses.Ada_For_Embedded_C_Dev.Concurrency.Rendezvous_Params
:class: ada-run-expect-variable-output

with Ada.Text_IO; use Ada.Text_IO;

Expand Down Expand Up @@ -266,6 +271,7 @@ is modified by other tasks that call :ada:`Increment`, :ada:`Decrement`, and
[Ada]

.. code:: ada run_button project=Courses.Ada_For_Embedded_C_Dev.Concurrency.Selective_Rendezvous
:class: ada-run-expect-variable-output

package Counters is

Expand Down Expand Up @@ -498,6 +504,7 @@ a binary semaphore / persistent signal.
[Ada]

.. code:: ada run_button project=Courses.Ada_For_Embedded_C_Dev.Concurrency.Protected_Binary_Semaphore
:class: ada-run-expect-variable-output

package Binary_Semaphores is

Expand Down Expand Up @@ -645,6 +652,7 @@ in the main application:
[Ada]

.. code:: ada run_button project=Courses.Ada_For_Embedded_C_Dev.Concurrency.Ravenscar
:class: ada-run-expect-variable-output

with My_Tasks; use My_Tasks;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -761,8 +761,8 @@ than the value passed to :ada:`X`.

Consider a client calling this function:

.. code:: ada no_button gnatprove=14.1.0-1 project=Courses.Ada_For_Embedded_C_Dev.SPARK.Contracts_2 switches=Compiler(-gnato23);
:class: ada-prove, ada-expect-prove-error
.. code:: ada prove_button project=Courses.Ada_For_Embedded_C_Dev.SPARK.Contracts_2 switches=Compiler(-gnato23);
:class: ada-expect-prove-error

with Mid;
with Ada.Text_IO; use Ada.Text_IO;
Expand All @@ -784,8 +784,7 @@ elsewhere.)
Let's change the argument passed to :ada:`Y` in the second call (line 8).
Instead of -1 we will pass -2:

.. code:: ada no_button gnatprove=14.1.0-1 project=Courses.Ada_For_Embedded_C_Dev.SPARK.Contracts_3 switches=Compiler(-gnato23);
:class: ada-prove
.. code:: ada prove_button project=Courses.Ada_For_Embedded_C_Dev.SPARK.Contracts_3 switches=Compiler(-gnato23);

with Mid;
with Ada.Text_IO; use Ada.Text_IO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1821,7 +1821,8 @@ Let's briefly recapitulate these approaches:

generic
type T is private;
with package SP is new Sig_Pkg (T, <>);
with package SP is new
Sig_Pkg (T, P => <>);
package Pkg is
end Pkg;

Expand Down Expand Up @@ -1974,7 +1975,7 @@ package:
generic
type T is private;
with package T_Hashable is new
Hashable_Signature (T, <>);
Hashable_Signature (T, Hash => <>);
package Hash_Tables is
-- Missing implementation
end Hash_Tables;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ All types implementing the :ada:`Animal` interface have to override the

end Animals.Cats;

.. code:: ada run_button project=Courses.Advanced_Ada.Abstraction-Oriented_Prog.OO_Prog.Extending_Interfaces
.. code:: ada run_button project=Courses.Advanced_Ada.Abstraction-Oriented_Prog.OO_Prog.Interfaces.Extending_Interfaces

with Animals.Cats; use Animals.Cats;

Expand Down Expand Up @@ -726,7 +726,7 @@ Here is a full example:

end Geo_Forms.Squares;

.. code:: ada run_button project=Courses.Advanced_Ada.Abstraction-Oriented_Prog.OO_Prog.Call_Inherited_Subprograms_2
.. code:: ada run_button project=Courses.Advanced_Ada.Abstraction-Oriented_Prog.OO_Prog.Calling_Inherited_Subprograms.Geometric_Forms_2

with Ada.Text_IO; use Ada.Text_IO;
with Geo_Forms.Squares; use Geo_Forms.Squares;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ actually passed. In fact, an :ada:`in out` parameter could be passed by copy.
For example:

.. code:: ada run_button project=Courses.Advanced_Ada.Control_Flow.Subprograms.Parameter_Modes_Associations.By_Copy_By_Ref_Params
:class: ada-run-expect-variable-output

with System;

Expand Down Expand Up @@ -196,6 +197,7 @@ more detail :ref:`in another chapter <Adv_Ada_Limited_Types_As_Parameters>`.
Let's see an example:

.. code:: ada run_button project=Courses.Advanced_Ada.Control_Flow.Subprograms.Parameter_Modes_Associations.By_Copy_By_Ref_Params
:class: ada-run-expect-variable-output

with System;

Expand Down Expand Up @@ -328,6 +330,7 @@ parameter. This situation could lead to undefined behavior or to a program
error. Consider the following code example:

.. code:: ada run_button project=Courses.Advanced_Ada.Control_Flow.Subprograms.Parameter_Modes_Associations.By_Copy_By_Ref_Params
:class: ada-run-expect-variable-output

with System;

Expand Down Expand Up @@ -421,6 +424,7 @@ Let's rewrite a previous code example that has a parameter of elementary type
and change it to *aliased*:

.. code:: ada run_button project=Courses.Advanced_Ada.Control_Flow.Subprograms.Parameter_Modes_Associations.By_Copy_By_Ref_Params
:class: ada-run-expect-variable-output

with System;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1370,6 +1370,7 @@ important to ensure that no :wikipedia:`race conditions <Race_condition>`
occur:

.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Shared_Variable_Control.Atomic_Operations.Exchange switches=Compiler(-gnat2022);
:class: ada-run-expect-variable-output

with System.Atomic_Operations.Exchange;

Expand Down Expand Up @@ -1514,6 +1515,7 @@ we'll use to generate random numbers in the expected range
Let's use this package in the :ada:`Show_Lazy_Initialization` procedure:

.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Shared_Variable_Control.Atomic_Operations.Compare_And_Exchange switches=Compiler(-gnat2022);
:class: ada-run-expect-variable-output

with Ada.Text_IO; use Ada.Text_IO;
with Ada.Numerics.Discrete_Random;
Expand Down Expand Up @@ -1664,6 +1666,7 @@ We can use these functions to implement an application similar to the
we've seen before:

.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Shared_Variable_Control.Atomic_Operations.Test_And_Set switches=Compiler(-gnat2022);
:class: ada-run-expect-variable-output

with System.Atomic_Operations.Test_And_Set;
use System.Atomic_Operations.Test_And_Set;
Expand Down Expand Up @@ -1789,6 +1792,7 @@ use the atomic operations from the
:ada:`System.Atomic_Operations.Integer_Arithmetic` package:

.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Shared_Variable_Control.Atomic_Operations.Integer_Arithmetic switches=Compiler(-gnat2022);
:class: ada-run-expect-variable-output

with System.Atomic_Operations.Integer_Arithmetic;

Expand Down Expand Up @@ -1855,6 +1859,7 @@ Let's reuse the
but replace the atomic integer type by an atomic modular type:

.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Shared_Variable_Control.Atomic_Operations.Modular_Arithmetic switches=Compiler(-gnat2022);
:class: ada-run-expect-variable-output

with System.Atomic_Operations.Modular_Arithmetic;

Expand Down
2 changes: 2 additions & 0 deletions content/courses/advanced-ada/parts/data_types/strings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1500,6 +1500,7 @@ scalar types, but it isn't restricted to those types. In fact, we can also use
this attribute when dealing with non-scalar types. For example:

.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Strings.Image_Attribute.Non_Scalar_Image switches=Compiler(-gnat2022);
:class: ada-run-expect-variable-output

package Simple_Records is

Expand Down Expand Up @@ -1662,6 +1663,7 @@ object of :ada:`Rec'Class` type. Also, we display the contents of the
We can also apply the :ada:`Image` attribute to protected objects and tasks:

.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Strings.Image_Attribute.Protected_Task_Image switches=Compiler(-gnat2022);
:class: ada-run-expect-variable-output

package Simple_Tasking is

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2464,6 +2464,7 @@ Here, we're assigning the address of the :ada:`I` object to the :ada:`A` address
example:

.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Type_Representation.Addresses.Show_Address_Attribute
:class: ada-run-expect-variable-output

with Ada.Text_IO; use Ada.Text_IO;
with System.Address_Image;
Expand Down Expand Up @@ -2493,6 +2494,7 @@ select an address automatically, but use the address that we're specifying. For
example:

.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Type_Representation.Addresses.Address_Aspect
:class: ada-run-expect-variable-output

with System; use System;
with System.Address_Image;
Expand Down Expand Up @@ -2594,6 +2596,7 @@ Address comparison
We can compare addresses using the common comparison operators. For example:

.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Type_Representation.Addresses.Address_Aspect
:class: ada-run-expect-variable-output

with System; use System;
with System.Address_Image;
Expand Down Expand Up @@ -2644,6 +2647,7 @@ using the :ada:`To_Address` and :ada:`To_Integer` functions. Let's see an
example:

.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Type_Representation.Addresses.Pointer_Arith_Ada
:class: ada-run-expect-variable-output

with System; use System;

Expand Down Expand Up @@ -2698,6 +2702,7 @@ a code example where we iterate over an array by incrementing an address that
*points* to each component in memory:

.. code:: ada run_button project=Courses.Advanced_Ada.Data_Types.Type_Representation.Addresses.Pointer_Arith_Ada
:class: ada-run-expect-variable-output

with System; use System;

Expand Down Expand Up @@ -2768,6 +2773,7 @@ see the section on
The code example above corresponds (more or less) to the following C code:

.. code:: c manual_chop run_button main=main.c project=Courses.Advanced_Ada.Data_Types.Type_Representation.Addresses.Pointer_Arith_C
:class: ada-run-expect-variable-output

!main.c
#include <stdio.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ type conversion is allowed is when both types have a common ancestor.
Let's see an example:

.. code:: ada run_button project=Courses.Advanced_Ada.Resource_Management.Access_Types.Access_Types_Allocation.Pool_Specific_Access_Types switches=Compiler(-gnat2022);
:class: ada-run-expect-variable-output

with Ada.Text_IO; use Ada.Text_IO;

Expand Down Expand Up @@ -356,6 +357,7 @@ the :ada:`A1 := A2` or the :ada:`A1 := Integer_Access_1 (A2)` assignment.)
For example:

.. code:: ada run_button project=Courses.Advanced_Ada.Resource_Management.Access_Types.Access_Types_Allocation.Array_Allocation switches=Compiler(-gnat2022);
:class: ada-run-expect-variable-output

with Ada.Text_IO; use Ada.Text_IO;

Expand Down Expand Up @@ -419,6 +421,7 @@ syntactic sugar is available to simplify the code that performs this
allocation. For example:

.. code:: ada run_button project=Courses.Advanced_Ada.Resource_Management.Access_Types.Access_Types_Allocation.Integer_Access_Array switches=Compiler(-gnat2022);
:class: ada-run-expect-variable-output

with Ada.Text_IO; use Ada.Text_IO;

Expand Down Expand Up @@ -467,6 +470,7 @@ designated objects with zero.)
Let's see another code example, this time with task types:

.. code:: ada run_button project=Courses.Advanced_Ada.Resource_Management.Access_Types.Access_Types_Allocation.Workers
:class: ada-run-expect-variable-output

package Workers is

Expand Down Expand Up @@ -6072,6 +6076,7 @@ convert between access types and addresses. This might be useful for specific
low-level operations. Let's see an example:

.. code:: ada run_button project=Courses.Advanced_Ada.Resource_Management.Access_Types.Access_Address.Address_Conversion
:class: ada-run-expect-variable-output

with Ada.Text_IO; use Ada.Text_IO;

Expand Down Expand Up @@ -6130,6 +6135,7 @@ is available to convert from an address to an object of access type. For
example:

.. code:: ada run_button project=Courses.Advanced_Ada.Resource_Management.Access_Types.Access_Address.Address_Conversion
:class: ada-run-expect-variable-output

with Ada.Text_IO; use Ada.Text_IO;
with System; use System;
Expand Down Expand Up @@ -6187,6 +6193,7 @@ Let's adapt the previous code example and replace the :ada:`Integer`
type by the (unbounded) :ada:`String` type:

.. code:: ada run_button project=Courses.Advanced_Ada.Resource_Management.Access_Types.Access_Address.Address_Conversion
:class: ada-run-expect-variable-output

with Ada.Text_IO; use Ada.Text_IO;
with System; use System;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ two scenarios:

Let's see a complete code example:

.. code:: ada no_button gnat=14.2.0-1 project=Courses.Advanced_Ada.Aggregates.Container_Aggregate_Empty switches=Compiler(-gnat2022);
:class: ada-run
.. code:: ada run_button project=Courses.Advanced_Ada.Aggregates.Container_Aggregate_Empty switches=Compiler(-gnat2022);

package Custom_Container_Aggregates is

Expand Down Expand Up @@ -250,8 +249,7 @@ needed.
In addition to this, we can specify a signed integer parameter |mdash| which
indicates the number of components |mdash| for the :ada:`Empty` function:

.. code:: ada no_button gnat=14.2.0-1 project=Courses.Advanced_Ada.Aggregates.Container_Aggregate_Empty switches=Compiler(-gnat2022);
:class: ada-run
.. code:: ada run_button project=Courses.Advanced_Ada.Aggregates.Container_Aggregate_Empty switches=Compiler(-gnat2022);

package Custom_Container_Aggregates is

Expand Down Expand Up @@ -336,8 +334,7 @@ of these elements: :ada:`Add_Unnamed`, :ada:`New_Indexed` or
:ada:`Assign_Indexed`. In other words, when we specify the :ada:`Add_Named`
element, we can only use the :ada:`Empty` element in the same declaration.

.. code:: ada no_button gnat=14.2.0-1 project=Courses.Advanced_Ada.Aggregates.Container_Aggregate_Named switches=Compiler(-gnat2022);
:class: ada-run
.. code:: ada run_button project=Courses.Advanced_Ada.Aggregates.Container_Aggregate_Named switches=Compiler(-gnat2022);

package Custom_Container_Aggregates is

Expand Down Expand Up @@ -441,8 +438,7 @@ procedure that is called when we have a positional container aggregate.

Let's look at an example:

.. code:: ada no_button gnat=14.2.0-1 project=Courses.Advanced_Ada.Aggregates.Container_Aggregate_Unnamed switches=Compiler(-gnat2022);
:class: ada-run
.. code:: ada run_button project=Courses.Advanced_Ada.Aggregates.Container_Aggregate_Unnamed switches=Compiler(-gnat2022);

package Custom_Container_Aggregates is

Expand Down Expand Up @@ -534,8 +530,7 @@ that, when we specify the :ada:`Assign_Indexed` element, we must also use the

Let's look at an example:

.. code:: ada no_button gnat=14.2.0-1 project=Courses.Advanced_Ada.Aggregates.Container_Aggregate_Indexed switches=Compiler(-gnat2022);
:class: ada-run
.. code:: ada run_button project=Courses.Advanced_Ada.Aggregates.Container_Aggregate_Indexed switches=Compiler(-gnat2022);

package Custom_Container_Aggregates is

Expand Down Expand Up @@ -684,8 +679,7 @@ As mentioned previously, we may specify both :ada:`Add_Named` and
:ada:`Assign_Indexed` elements together in the same aspect declaration. For
example:

.. code:: ada no_button gnat=14.2.0-1 project=Courses.Advanced_Ada.Aggregates.Container_Aggregate_Unnamed_Indexed switches=Compiler(-gnat2022);
:class: ada-run
.. code:: ada run_button project=Courses.Advanced_Ada.Aggregates.Container_Aggregate_Unnamed_Indexed switches=Compiler(-gnat2022);

package Custom_Container_Aggregates is

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2444,6 +2444,7 @@ For example, we can see this when looking at the address of the object
type :ada:`Simple_Rec`:

.. code:: ada run_button project=Courses.Advanced_Ada.Resource_Management.Limited_Types.Extended_Return_Statements_Limited_Types.Initialization_Return_Do
:class: ada-run-expect-variable-output

package Limited_Types is

Expand Down Expand Up @@ -2523,6 +2524,7 @@ procedure are the same object.
nonlimited:

.. code:: ada run_button project=Courses.Advanced_Ada.Resource_Management.Limited_Types.Extended_Return_Statements_Limited_Types.Initialization_Return_Copy
:class: ada-run-expect-variable-output

package Non_Limited_Types is

Expand Down Expand Up @@ -2837,6 +2839,7 @@ We can run the :ada:`Test` application below and compare the address of the
not:

.. code:: ada run_button project=Courses.Advanced_Ada.Resource_Management.Limited_Types.Limited_Types_Parameters.Explicitly_Limited_Types
:class: ada-run-expect-variable-output

with System;

Expand Down
Loading
Loading