Skip to content

Commit ede12ce

Browse files
committed
Editorial suggestions from T. Taft
Various editorial suggestions from T. Taft.
1 parent 62ecbdc commit ede12ce

File tree

5 files changed

+21
-20
lines changed

5 files changed

+21
-20
lines changed

content/courses/ada-idioms/chapters/abstract_data_machines.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ following:
8383
- Operations
8484

8585
The package declaration's private part and the package body may contain all
86-
the above, but one or the other (or both) will contain object declarations
86+
the above, but one or the other (or both) will contain variable declarations
8787
representing the abstraction's state.
8888

8989
Consider the following ADM version of the package :ada:`Integer_Stacks`, now
@@ -115,14 +115,14 @@ version we declare the state in the package body.
115115
end Integer_Stack;
116116
117117
Now there is no type presenting a :ada:`Stack` abstraction and the operations
118-
do not take a stack parameter because the package and its data is the instance
118+
do not take a stack parameter because the package and its data together are the instance
119119
of the abstraction. When using this idiom, there is only one stack of integers.
120120
That's why we changed the name of the package from :ada:`Integer_Stacks`, i.e.,
121121
from the plural form to the singular.
122122

123123
As with the ADT idiom, clients of an ADM can only manipulate the encapsulated
124124
state indirectly, via the visible operations. The difference is that the state
125-
to be manipulated is no longer a formal parameter. For example:
125+
to be manipulated is no longer a formal parameter of the operations. For example:
126126

127127
.. code-block:: ada
128128
@@ -138,7 +138,7 @@ type :ada:`Stack` are manipulated:
138138
-- ...
139139
Push (Answers, 42);
140140
141-
That call places the value 42 in the array :ada:`Answers.Values`, i.e., within
141+
That call places the value 42 in the (hidden) array :ada:`Answers.Values`, i.e., within
142142
the :ada:`Answers` variable. Clients can declare as many :ada:`Stack` objects
143143
as they require, each containing a distinct copy of the state defined by the
144144
type. In the ADM version, there is only one stack and therefore only one instance
@@ -170,13 +170,13 @@ The private section wasn't otherwise required when we chose to declare the data
170170
the package body.
171171

172172
The ADM idiom applies information hiding to the internal state, like the
173-
ADT idiom, except that the state is not in objects. Also, like the
173+
ADT idiom, except that the state is not in objects declared in the client. Also, like the
174174
:ref:`Groups of Related Program Units <Ada_Idioms_Groups_Of_Related_Program_Units>`,
175175
the implementations of the visible subprograms are hidden in the package body,
176176
along with any non-visible entities required for their implementation.
177177

178178
There are no constructor functions returning a value of the abstraction
179-
type because there is no such type with the ADM. However, there could be one or
179+
type because there is no such type within the ADM. However, there could be one or
180180
more initialization procedures, operating directly on the hidden state in the
181181
package private part or package body. In the :ada:`Stack` ADM there is no need
182182
because of the reasonable initial state, as is true with the ADT version.

content/courses/ada-idioms/chapters/abstract_data_types.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ client compile-time visibility to the type's representation is both an
1414
advantage and a disadvantage. Visibility to the representation makes available
1515
the expressiveness of low-level syntax, such as array indexing and aggregates,
1616
but in so doing allows client source code to be dependent on the
17-
representation. In the vast majority of cases, the resulting economic and
18-
engineering disadvantages far outweigh the expressiveness advantages.
17+
representation. In many cases, the resulting economic and
18+
engineering disadvantages of visibility on the representation will
19+
outweigh the expressiveness advantages.
1920

2021
For the sake of illustration, let's create a *stack* type that can contain
2122
values of type :ada:`Integer`. (We use type :ada:`Integer` purely for the sake
@@ -111,7 +112,7 @@ The ADT may also be abstract in the sense of object-oriented programming but
111112
that is an unrelated issue.
112113

113114
In Ada we use *private types* to define abstract data types because private
114-
types make the type's name, but not the representation, visible to clients.
115+
types make the type's name, but not its representation, visible to clients.
115116
These types are composed using syntactical building blocks: a package
116117
declaration, separated into two parts, containing a type declared in two parts,
117118
and containing declarations for subprograms to manipulate objects of the type
@@ -203,7 +204,7 @@ The full type definition is in the package private part. Therefore, for
203204
any given object of the type, the representation details |mdash| the two
204205
record components in this example |mdash| can't be referenced in client code.
205206
Clients must instead only use the operations defined by the package, passing
206-
the client objects to the formal parameters. Only the bodies of these operations
207+
the client objects as the actual parameters. Only the bodies of these operations
207208
have compile-time visibility to the representation of the :ada:`Stack`
208209
parameters, so only they can implement the functionality for those parameters.
209210

@@ -216,7 +217,7 @@ mentioned, basic operations such as assignment are allowed, unless the ADT is
216217
abstraction.
217218

218219
You may, of course, also require other ancillary type declarations in the
219-
package, either for the implementation or as additional parameters for the
220+
package, either for the implementation or as types for additional parameters for the
220221
visible operations. The array type :ada:`Content` is an example of the
221222
former case. When it is strictly an implementation artifact, as in this
222223
case, it should be in the private part so that it's hidden from clients.
@@ -279,7 +280,7 @@ There may be cases when what looks like an accessor function is provided, when
279280
in fact the function computes the return value. Similarly, there may be
280281
functions that simply return the value of a component but are part of the
281282
abstraction and happen to be implementable by returning the value of a
282-
component. For example, a real stacks ADT package would include a function
283+
component. For example, a real stack's ADT package would include a function
283284
indicating the extent of the object |mdash| that is, the number of values
284285
currently contained. In our example implementation the :ada:`Top` component happens to
285286
indicate that value, in addition to indicating the current top of the stack. The body

content/courses/ada-idioms/chapters/constructor_functions_for_abstract_data_types.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ the type declaration itself. For procedures, that means they have formal
7070
parameters of the type. For functions, that means they either have formal
7171
parameters of the type, or return a value of the type, or both.
7272

73-
Declaration with the same package as the type itself provides the
73+
Declaration within the same package as the type itself provides the
7474
compile-time visibility to the type's representation required to
7575
implement the subprograms.
7676

@@ -136,7 +136,7 @@ Therefore, unless the extended child type is itself abstract, the type extension
136136
will be illegal. The compiler will reject the declaration of the child type,
137137
thus preventing this inappropriate constructor inheritance.
138138

139-
For an example, both for the code and the Ada rules, consider this simple
139+
For an example, both to illustrate the code and the Ada rules, consider this simple
140140
package declaration that presents the tagged private type
141141
:ada:`Graphics.Shape`:
142142

@@ -223,8 +223,7 @@ compile-time visibility that primitive operations have.
223223

224224
Therefore, the specific solution is to declare constructor functions in a
225225
separate package that is a *child* of the package declaring the tagged type.
226-
The actual term is a *hierarchical library package* but *child* conveys the
227-
concept and is less of a mouthful.
226+
This takes advantage of the *hierarchical library units* capability introduced in Ada 95.
228227

229228
Operations declared in a child package are not primitive operations for the
230229
type in the parent package, so they are not inherited when that type is
@@ -317,7 +316,8 @@ locating individual entities of interest, any decent IDE will make doing so
317316
trivial.)
318317

319318
The alternative also loses the distinction between clients that use objects of
320-
the type and clients that create those objects, because the latter will have
319+
the type and clients that create those objects, because, with the child package
320+
approach, the latter will be the only clients that have
321321
context clauses for the constructor packages.
322322

323323

content/courses/ada-idioms/chapters/controlling_obj_initialization_creation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ most commonly used non-numeric type in the language. Sometimes a given type was
2424
initialization, e.g., numeric types. That wrapping approach is less common than
2525
in earlier versions of the language, given the comparatively more recent aspect
2626
:ada:`Default_Value` for scalar types, and :ada:`Default_Component_Value` for
27-
scalar components.
27+
scalar array components.
2828

2929
These facilities are often sufficient to express an abstraction's initial
3030
state. For example, we can expect that container objects will be initially

content/courses/ada-idioms/chapters/programming_by_extension.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,12 @@ Notes
227227
-----
228228

229229
This guideline will already be used when developing a subsystem (a set of
230-
related packages in a common hierarchy) as a structuring approach during
230+
related packages in an overall hierarchy) as a structuring approach during
231231
initial development. The idiom discussed here is yet another reason to use the
232232
private part, but in this case for the sake of the future, rather than initial,
233233
development.
234234

235-
The very first version of Ada (Ada 83) did not have hierarchical packages so,
235+
The very first version of Ada (Ada 83) did not have hierarchical library units so,
236236
typically, anything not required in the private part was declared in the
237237
package body. Declaring them in the private part would only clutter the code
238238
that had to be there, without any benefit. The author's personal experience and

0 commit comments

Comments
 (0)