Skip to content

Replace most occurrences of "element" with "component" #506

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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 @@ -9,19 +9,19 @@ Language-Defined Character Types
* :ada:`Character`

- 8-bit Latin-1
- Base element of :ada:`String`
- Base component of :ada:`String`
- Uses attributes :ada:`'Image` / :ada:`'Value`

* :ada:`Wide_Character`

- 16-bit Unicode
- Base element of :ada:`Wide_Strings`
- Base component of :ada:`Wide_Strings`
- Uses attributes :ada:`'Wide_Image` / :ada:`'Wide_Value`

* :ada:`Wide_Wide_Character`

- 32-bit Unicode
- Base element of :ada:`Wide_Wide_Strings`
- Base component of :ada:`Wide_Wide_Strings`
- Uses attributes :ada:`'Wide_Wide_Image` / :ada:`'Wide_Wide_Value`

-----------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ Quiz

Explanations

A. Legal - elements are :ada:`Boolean`
A. Legal - components are :ada:`Boolean`
B. Legal - object types match
C. Legal - elements are :ada:`Boolean`
D. Although the sizes are the same and the elements are the same, the type is different
C. Legal - components are :ada:`Boolean`
D. Although the sizes are the same and the components are the same, the type is different

Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Null Index Range

* When :ada:`'Last` of the range is smaller than :ada:`'First`

* Array is empty - no elements
* Array is empty - no components

* When using literals, the compiler will allow out-of-range numbers to indicate empty range

Expand Down Expand Up @@ -189,7 +189,7 @@ Indefinite Types
No Indefinite Component Types
-------------------------------

* Arrays: consecutive elements of the exact **same type**
* Arrays: consecutive components of the exact **same type**
* Component size must be **defined**

- No indefinite types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ Which statement(s) is (are) legal?
Explanations

A. All objects are just Boolean values
B. An element of :ada:`A` is the same type as :ada:`B`
B. A component of :ada:`A` is the same type as :ada:`B`
C. Slice must be of outermost array
D. Slicing allowed on single-dimension arrays

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Note on Default Initialization for Array Types
------------------------------------------------

* In Ada, objects are not initialized by default
* To initialize an array, you can initialize each element
* To initialize an array, you can initialize each component

* But if the array type is used in multiple places, it would be better to initialize at the type level
* No matter how many dimensions, there is only one component type
Expand Down Expand Up @@ -51,7 +51,7 @@ Two High-Level For-Loop Kinds
Array/Container For-Loops
---------------------------

* Work in terms of elements within an object
* Work in terms of components within an object
* Syntax hides indexing/iterator controls

.. code:: Ada
Expand All @@ -60,7 +60,7 @@ Array/Container For-Loops
...
end loop;

* Starts with "first" element unless you reverse it
* Starts with "first" component unless you reverse it
* Loop parameter name is a constant if iterating over a constant, a variable otherwise

..
Expand Down
4 changes: 2 additions & 2 deletions courses/fundamentals_of_ada/050_array_types/07-aggregates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ Aggregates in Ada 2022
Illegal : Array_T := ();
Ada2022 : Array_T := [];

* Single element array
* Single component array

.. code:: Ada

Expand Down Expand Up @@ -308,7 +308,7 @@ Iterated Component Association

Object2 := [for Item of Object => Item * 2];

* :ada:`Object2` will have each element doubled
* :ada:`Object2` will have each component doubled

-------------------------------
More Information on Iterators
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Mutable Variant Record

* An object can be created without a constraint (:ada:`Pat`)
* Or we can create in immutable object where the discriminant cannot change (:ada:`Sam`)
* And we can create an array whose element is mutable
* And we can create an array whose component is mutable

--------------------------------
Mutable Variant Record Example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ Vectors of Varying Lengths
+ Need two pieces of data

* Array contents
* Location of last valid element
* Location of last valid component

* For common usage, we want this to be a type (probably a record)

+ Maximum size array for contents
+ Index for last valid element
+ Index for last valid component

---------------------------------
Simple Vector of Varying Length
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Type Derivation
Reminder: What is a Type?
---------------------------

* A type is characterized by two elements
* A type is characterized by two components

- Its data structure
- The set of operations that applies to it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,8 @@ Quiz
type Array2_T is array (1 .. 3) of Array1_T;
A : Array2_T;

The above describes an array A whose elements are arrays of three elements.
Which expression would one use to determine if at least one of A's elements are sorted?
The above describes an array A whose components are arrays of three components.
Which expression would one use to determine if at least one of A's components are sorted?

A. | ``(for some El of A => (for some Idx in 2 .. 3 =>``
| ``El (Idx) >= El (Idx - 1)));``
Expand All @@ -368,8 +368,8 @@ D. | ``(for all El of A => (for some Idx in 2 .. 3 =>``

.. container:: animate

A. Will be :ada:`True` if any element has two consecutive increasing values
B. Will be :ada:`True` if every element is sorted
A. Will be :ada:`True` if any component has two consecutive increasing values
B. Will be :ada:`True` if every component is sorted
C. Correct
D. Will be :ada:`True` if every element has two consecutive increasing values
D. Will be :ada:`True` if every component has two consecutive increasing values

Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ When to Avoid Private Types

- Those that cannot be redefined by programmers
- Would otherwise be hidden by a private type
- If `Vector` is private, indexing of elements is annoying
- If `Vector` is private, indexing of components is annoying

.. code:: Ada

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Composites with Limited Types

* Composite containing a limited type becomes limited as well

* Example: Array of limited elements
* Example: Array of limited components

- Array becomes a limited type

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ The "renames" Keyword

package Trig renames Math.Trigonometry

- Objects (or elements of objects)
- Objects (or components of objects)

.. code:: Ada

Expand Down
6 changes: 3 additions & 3 deletions courses/fundamentals_of_ada/135_visibility/05-lab.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ Visibility Lab

+ :ada:`Number_of_Sides` - indicates how many sides in the shape
+ :ada:`Side_T` - numeric value for length
+ :ada:`Shape_T` - array of :ada:`Side_T` elements whose length is :ada:`Number_of_Sides`
+ :ada:`Shape_T` - array of :ada:`Side_T` components whose length is :ada:`Number_of_Sides`

- Create a main program that will

+ Create an object of each :ada:`Shape_T`
+ Set the values for each element in :ada:`Shape_T`
+ Add all the elements in each object and print the total
+ Set the values for each component in :ada:`Shape_T`
+ Add all the components in each object and print the total

* Hints

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ Generic Parameters Can Be Combined
type Acc is access all T;
type Index is (<>);
type Arr is array (Index range <>) of Acc;
function Element (Source : Arr;
Position : Index)
return T;
function Component (Source : Arr;
Position : Index)
return T;

type String_Ptr is access all String;
type String_Array is array (Integer range <>)
of String_Ptr;

function String_Element is new Element
function String_Component is new Component
(T => String,
Acc => String_Ptr,
Index => Integer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ Generic Constants/Variables As Parameters
.. code:: Ada

generic
type Element_T is private;
type Component_T is private;
Array_Size : Positive;
High_Watermark : in out Element_T;
High_Watermark : in out Component_T;
package Repository is

* Generic instance
Expand All @@ -40,7 +40,7 @@ Generic Constants/Variables As Parameters
Max : Float;

procedure My_Repository is new Repository
(Element_T => Float,
(Component_T => Float,
Array_size => 10,
High_Watermark => Max);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ Arrays Interfacing
Arrays From Ada to C
----------------------

* An Ada array is a composite data structure containing 2 elements: Bounds and Elements
* An Ada array is a composite data structure containing 2 components: Bounds and Components

- **Fat pointers**

* When arrays can be sent from Ada to C, C will only receive an access to the elements of the array
* When arrays can be sent from Ada to C, C will only receive an access to the components of the array
* Ada View

.. code:: Ada
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,21 +107,21 @@ Interfaces.C.Pointers

generic
type Index is (<>);
type Element is private;
type Element_Array is array (Index range <>) of aliased Element;
Default_Terminator : Element;
type Component is private;
type Component_Array is array (Index range <>) of aliased Component;
Default_Terminator : Component;

package Interfaces.C.Pointers is

type Pointer is access all Element;
type Pointer is access all Component;
for Pointer'Size use System.Parameters.ptr_bits;

function Value (Ref : Pointer;
Terminator : Element := Default_Terminator)
return Element_Array;
Terminator : Component := Default_Terminator)
return Component_Array;
function Value (Ref : Pointer;
Length : ptrdiff_t)
return Element_Array;
return Component_Array;

Pointer_Error : exception;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ Quiz
.. code:: Ada

type Index_T is range 1 .. 100;
-- Database initialized such that value for element at I = I
-- Database initialized such that value for component at I = I
Database : array (Index_T) of Integer;
-- Set the value for element Index to Value and
-- Set the value for component Index to Value and
-- then increment Index by 1
function Set_And_Move (Value : Integer;
Index : in out Index_T)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Quiz
.. code:: Ada

Database : String (1 .. 10) := "ABCDEFGHIJ";
-- Set the value for the element at position Index in
-- Set the value for the component at position Index in
-- array Database to Value and then increment Index by 1
function Set_And_Move (Value : Character;
Index : in out Index_T)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Ada.Text_IO

- `Ada.Sequential_IO` and `Ada.Direct_IO`

* Operations on binary files for elements of a given type
* Operations on binary files for components of a given type

- `Ada.Storage_IO`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Data Structures (1/2)
- Containers matching Key -> Element
- Not a one-to-one relationship

+ Can have several keys for a single element
+ Can have several keys for a single component

* Set

Expand Down Expand Up @@ -49,7 +49,7 @@ Data Structures (2/2)

- Wraps around an indefinite (unconstrained, class-wide ...)
- Resulting type is definite
- Single element, no iteration or cursor
- Single component, no iteration or cursor

..
language_version 2012
Expand All @@ -61,7 +61,7 @@ Implementations (1/2)
* :dfn:`Bounded`

- Maximal storage is bounded
- Constant :dfn:`capacity` and element size
- Constant :dfn:`capacity` and component size
- Only static allocation
- :ada:`Bounded_<Structure>`

Expand All @@ -73,14 +73,14 @@ Implementations (1/2)

* :dfn:`Ordered`

- Elements are sorted in order
- Components are sorted in order
- Must provide :ada:`<` and :ada:`=` operators
- Not hashed
- :ada:`XXX_Ordered_<Structure>`

* :dfn:`Hashed`

- Elements are hashed
- Components are hashed
- Must provide :ada:`Hash` function and :ada:`=` operator
- Not ordered
- Some hash functions are provided (e.g. :ada:`Ada.Strings.Hash`)
Expand All @@ -92,8 +92,8 @@ Implementations (2/2)

* :dfn:`Indefinite`

- Element can be indefinite
- Size of element is unknown
- Component can be indefinite
- Size of component is unknown
- :ada:`Indefinite_XXX_<Structure>`

..
Expand All @@ -107,18 +107,18 @@ Example of Containers
* :ada:`Indefinite_Vector`

- Static capacity
- Dynamically sized (indefinite elements)
- Dynamically sized (indefinite components)
- Random access in ``O(1)``

* :ada:`Ordered_Set`

- Unique elements
- Unique components
- Differentiated by :ada:`<` and :ada:`=`
- Manipulated in order

* :ada:`Bounded_Doubly_Linked_List`

- Static size of container and elements
- Static size of container and components
- Insertions and deletions in ``O(1)``

-------------
Expand Down
Loading
Loading