Skip to content

Commit 3026a91

Browse files
Merge branch 'slides/116-update-slides-to-remove-some-ada-2012-references' into 'master'
Resolve "Update slides to remove some Ada 2012 references" Closes #116 See merge request feng/training/material!210
2 parents caeb19a + 5cc7436 commit 3026a91

15 files changed

+172
-229
lines changed

courses/fundamentals_of_ada/020_declarations.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -834,12 +834,12 @@ Aspect Clause Example: Objects
834834

835835
.. code:: Ada
836836
837+
-- using aspects
837838
CR1 : Control_Register with
838839
Size => 8,
839840
Address => To_Address (16#DEAD_BEEF#);
840841
841-
-- Prior to Ada 2012
842-
-- using *representation clauses*
842+
-- using representation clauses
843843
CR2 : Control_Register;
844844
for CR2'Size use 8;
845845
for CR2'Address use To_Address (16#DEAD_BEEF#);

courses/fundamentals_of_ada/040_statements.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -601,10 +601,6 @@ Basic Loops and Syntax
601601
Rinse (Hair);
602602
end loop Wash_Hair;
603603
604-
.. container:: speakernote
605-
606-
Loop Iterator Specification available in Ada2012 and later
607-
608604
--------------------
609605
Loop Exit Statements
610606
--------------------
@@ -698,7 +694,6 @@ For-loop Statements
698694

699695
* Two high-level forms
700696

701-
- Ada 2012
702697
- Focused on objects
703698
- Seen later with Arrays
704699

courses/fundamentals_of_ada/050_array_types.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Array Types
3636
.. include:: 050_array_types/03-unconstrained_array_types.rst
3737
.. include:: 050_array_types/04-attributes.rst
3838
.. include:: 050_array_types/05-operations.rst
39-
.. include:: 050_array_types/06-operations_added_for_ada2012.rst
39+
.. include:: 050_array_types/06-looping_over_objects.rst
4040
.. include:: 050_array_types/07-aggregates.rst
4141
.. include:: 050_array_types/08-detour_image_for_complex_types.rst
4242
.. include:: 050_array_types/09-anonymous_array_types.rst

courses/fundamentals_of_ada/050_array_types/06-operations_added_for_ada2012.rst renamed to courses/fundamentals_of_ada/050_array_types/06-looping_over_objects.rst

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
==============================
2-
Operations Added for Ada2012
2+
Looping Over Array Components
33
==============================
44

5-
----------------------------------------
6-
Default Initialization for Array Types
7-
----------------------------------------
5+
------------------------------------------------
6+
Note on Default Initialization for Array Types
7+
------------------------------------------------
88

9-
* Supports constrained and unconstrained array types
10-
* Supports arrays of any dimensionality
9+
* In Ada, objects are not initialized by default
10+
* To initialize an array, you can initialize each element
1111

12-
- No matter how many dimensions, there is only one component type
12+
* But if the array type is used in multiple places, it would be better to initialize at the type level
13+
* No matter how many dimensions, there is only one component type
1314

1415
* Uses aspect `Default_Component_Value`
1516

courses/fundamentals_of_ada/070_subprograms.rst

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -962,8 +962,11 @@ Parameter Aliasing
962962
963963
procedure Update (Doubled, Tripled : in out Integer);
964964
...
965-
Update (Doubled => A,
966-
Tripled => A); -- illegal in Ada 2012
965+
Update (Doubled => A, Tripled => A);
966+
967+
.. container:: latex_environment footnotesize
968+
969+
:command:`error: writable actual for "Doubled" overlaps with actual for "Tripled"`
967970

968971
----------------------------
969972
Functions' Parameter Modes
@@ -975,7 +978,7 @@ Functions' Parameter Modes
975978
- Including those you overload
976979
- Keeps readers sane
977980

978-
* Justification for only mode :ada:`in` prior to Ada 2012
981+
* Justification for only mode :ada:`in` in earlier versions of the language
979982

980983
- No side effects: should be like mathematical functions
981984
- But side effects are still possible via globals
@@ -1045,13 +1048,6 @@ Tic-Tac-Toe Winners Example (Spec)
10451048
- :subscript:`8` N
10461049
- :subscript:`9` N
10471050

1048-
.. container:: speakernote
1049-
1050-
Prior to Ada2012 use:
1051-
type Game is record
1052-
Board : Moves := (others ``=>`` Nobody);
1053-
end record;
1054-
10551051
------------------------------------
10561052
Tic-Tac-Toe Winners Example (Body)
10571053
------------------------------------

courses/fundamentals_of_ada/090_overloading/05-composition_of_equality.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ User-Defined Equality Composition
9191

9292
* No issue for all language-defined types in all versions of Ada
9393
* An issue for user-defined types
94-
* Only automatic for :ada:`record` types in Ada 2012
95-
* Only automatic for :ada:`tagged record` types in Ada 2005
94+
* Became automatic for :ada:`record` types in Ada 2012
95+
* Became automatic for :ada:`tagged record` types in Ada 2005
9696

9797
- Otherwise need explicit equality function for enclosing type
9898

courses/fundamentals_of_ada/130_program_structure.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,7 @@ Summary
980980

981981
- Direct support for subsystems
982982
- Extension without recompilation
983-
- Separation of concerns with controlled sharing of visibility (Ada 2012)
983+
- Separation of concerns with controlled sharing of visibility
984984

985985
* Parents should document assumptions for children
986986

courses/fundamentals_of_ada/135_visibility.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,10 @@ No Ambiguity Introduction
294294
295295
use all type subtype_mark {, subtype_mark};
296296
297-
* More specific alternative to :ada:`use` clauses
297+
* More specific alternatives to :ada:`use` clauses
298298

299299
- Especially useful when multiple :ada:`use` clauses introduce ambiguity
300300

301-
*Note that* :ada:`use all type` *was introduced in Ada 2012*
302-
303301
--------------
304302
Example Code
305303
--------------
@@ -496,8 +494,6 @@ Summary
496494

497495
* :ada:`use all type` clauses are more likely in practice than :ada:`use type` clauses
498496

499-
- Only available in Ada 2012 and later
500-
501497
* :ada:`Renames` allow us to alias entities to make code easier to read
502498

503499
- Subprogram renaming has many other uses, such as adding / removing default parameter values

courses/fundamentals_of_ada/230_interfacing_with_c.rst

Lines changed: 55 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -56,49 +56,50 @@ Introduction
5656
Import / Export
5757
=================
5858

59-
------------------------------
60-
Pragma Import / Export (1/2)
61-
------------------------------
59+
-------------------------------
60+
Import / Export Aspects (1/2)
61+
-------------------------------
6262

63-
* :ada:`pragma Import` allows a C implementation to complete an Ada specification
63+
* Aspects :ada:`Import` and :ada:`Export` allow Ada and C to interact
6464

65-
- Ada view
65+
* :ada:`Import` indicates a subprogram imported into Ada
66+
* :ada:`Export` indicates a subprogram exported from Ada
6667

67-
.. code:: Ada
68+
* Need aspects definining calling convention and external name
6869

69-
procedure C_Proc;
70-
pragma Import (C, C_Proc, "SomeProcedure");
70+
* :ada:`Convention => C` tells linker to use C-style calling convention
71+
* :ada:`External_Name => "<name>"` defines object name for linker
7172

72-
- C implementation
73+
* Ada implementation
7374

74-
.. code:: C
75-
76-
void SomeProcedure (void) {
77-
// some code
78-
}
75+
.. code:: Ada
7976
80-
* :ada:`pragma Export` allows an Ada implementation to complete a C specification
77+
procedure Imported_From_C with
78+
Import,
79+
Convention => C,
80+
External_Name => "SomeProcedureInC";
8181
82-
- Ada implementation
82+
procedure Exported_To_C with
83+
Export,
84+
Convention => C,
85+
External_Name => "some_ada_procedure;
8386
84-
.. code:: Ada
87+
* C implementation
8588

86-
procedure Some_Procedure;
87-
pragma Export (C, Some_Procedure, "ada_some_procedure");
88-
procedure Some_Procedure is
89-
begin
90-
-- some code
91-
end Some_Procedure;
89+
.. code:: C
9290
93-
- C view
91+
void SomeProcedureInC (void) {
92+
// some code
93+
}
9494
95-
.. code:: C
95+
extern void ada_some_procedure (void);
9696
97-
extern void ada_some_procedure (void);
97+
..
98+
language_version 2012
9899
99-
------------------------------
100-
Pragma Import / Export (2/2)
101-
------------------------------
100+
-------------------------------
101+
Import / Export Aspects (2/2)
102+
-------------------------------
102103

103104
* You can also import/export variables
104105

@@ -107,7 +108,10 @@ Pragma Import / Export (2/2)
107108

108109
.. code:: Ada
109110
110-
My_Var : integer_type;
111+
My_Var : Integer_Type with
112+
Import,
113+
Convention => C,
114+
External_Name => "my_var";
111115
Pragma Import (C, My_Var, "my_var");
112116
113117
- C implementation
@@ -116,21 +120,22 @@ Pragma Import / Export (2/2)
116120
117121
int my_var;
118122
119-
-----------------------------
120-
Import / Export in Ada 2012
121-
-----------------------------
123+
..
124+
language_version 2012
125+
126+
------------------------------
127+
Import / Export with Pragmas
128+
------------------------------
122129

123-
* In Ada 2012, :ada:`Import` and :ada:`Export` can also be done using aspects:
130+
* You can also use :ada:`pragma` to import/export entities
124131

125132
.. code:: Ada
126133
127-
procedure C_Proc
128-
with Import,
129-
Convention => C,
130-
External_Name => "c_proc";
134+
procedure C_Some_Procedure;
135+
pragma Import (C, C_Some_Procedure, "SomeProcedure");
131136
132-
..
133-
language_version 2012
137+
procedure Some_Procedure;
138+
pragma Export (C, Some_Procedure, "ada_some_procedure");
134139
135140
===================
136141
Parameter Passing
@@ -198,24 +203,26 @@ Passing Structures As Parameters
198203
* Ada View
199204

200205
.. code:: Ada
201-
202-
type Enum is (E1, E2, E3);
203-
Pragma Convention (C, Enum);
206+
type Enum is (E1, E2, E3) with Convention => C;
204207
type Rec is record
205208
A, B : int;
206209
C : Enum;
207-
end record;
208-
Pragma Convention (C, Rec);
210+
end record with Convention => C;
209211
210-
* Using Ada 2012 aspects
212+
* This can also be done with pragmas
211213

212214
.. code:: Ada
213215
214-
type Enum is (E1, E2, E3) with Convention => C;
216+
type Enum is (E1, E2, E3);
217+
Pragma Convention (C, Enum);
215218
type Rec is record
216219
A, B : int;
217220
C : Enum;
218-
end record with Convention => C;
221+
end record;
222+
Pragma Convention (C, Rec);
223+
224+
..
225+
language_version 2012
219226
220227
-----------------
221228
Parameter Modes

courses/fundamentals_of_ada/270_introduction_to_contracts.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ Ada Contracts
6464
- At compile-time: specific constructs, features, and rules
6565
- At run-time: language-defined and user-defined exceptions
6666

67-
* Facilities prior to Ada 2012
67+
* Facilities as part of the language definition
6868

6969
- Range specifications
7070
- Parameter modes
7171
- Generic contracts
72-
- OOP :ada:`interface` types (Ada 2005)
72+
- OOP :ada:`interface` types
7373
- Work well, but on a restricted set of use-cases
7474

75-
* Contracts aspects are explicitly added in **Ada 2012**
75+
* Contract aspects to be more expressive
7676

7777
- Carried by subprograms
7878
- ... or by types (seen later)
@@ -145,7 +145,7 @@ Quiz
145145

146146
Which of the following statements is (are) correct?
147147

148-
A. Contract principles apply only to Ada 2012
148+
A. Contract principles apply only to newer versions of the language
149149
B. :answer:`Contract should hold even for unique conditions and corner cases`
150150
C. Contract principles were first implemented in Ada
151151
D. You cannot be both supplier and client
@@ -154,7 +154,7 @@ Which of the following statements is (are) correct?
154154

155155
Explanations
156156

157-
A. No, but design-by-contract **aspects** are fully integrated to Ada 2012 design
157+
A. No, but design-by-contract **aspects** were fully integrated into Ada 2012
158158
B. Yes, special case should be included in the contract
159159
C. No, in eiffel, in 1986!
160160
D. No, in fact you are always **both**, even the :ada:`Main` has a caller!

0 commit comments

Comments
 (0)