Skip to content

Replace word "field" with "component" #505

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 1 commit 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 @@ -114,7 +114,7 @@ Categories of Types
Scalar Types
--------------

* Indivisible: No components
* Indivisible: No :dfn:`components` (also known as *fields* or *elements*)
* **Relational** operators defined (``<``, ``=``, ...)

- **Ordered**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ Syntax and Examples
.. code:: Ada

type Record1_T is record
Field1 : Integer;
Field2 : Boolean;
Component1 : Integer;
Component2 : Boolean;
end record;

* Records can be **discriminated** as well
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ Quiz
.. code:: Ada

type Nested_T is record
Field : Integer;
Component : Integer;
end record;
type Record_T is record
One : Integer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Immutable Variant Record
type Person_Group is (Student, Faculty);
type Person (Group : Person_Group) is
record
-- Fields common across all discriminants
-- Components common across all discriminants
-- (must appear before variant part)
Age : Positive;
case Group is -- Variant part of record
Expand All @@ -46,11 +46,11 @@ Immutable Variant Record
* In a variant record, a discriminant can be used to specify the :dfn:`variant part` (line 8)

+ Similar to case statements (all values must be covered)
+ Fields listed will only be visible if choice matches discriminant
+ Field names need to be unique (even across discriminants)
+ Components listed will only be visible if choice matches discriminant
+ Component names need to be unique (even across discriminants)
+ Variant part must be end of record (hence only one variant part allowed)

* Discriminant is treated as any other field
* Discriminant is treated as any other component

* But is a constant in an immutable variant record

Expand All @@ -60,7 +60,7 @@ Immutable Variant Record
Immutable Variant Record Example
----------------------------------

* Each object of :ada:`Person` has three fields, but it depends on :ada:`Group`
* Each object of :ada:`Person` has three components, but it depends on :ada:`Group`

.. code:: Ada

Expand All @@ -69,7 +69,7 @@ Immutable Variant Record Example

* :ada:`Pat` has :ada:`Group`, :ada:`Age`, and :ada:`Gpa`
* :ada:`Sam` has :ada:`Group`, :ada:`Age`, and :ada:`Pubs`
* Aggregate specifies all fields, including the discriminant
* Aggregate specifies all components, including the discriminant

* Compiler can detect some problems, but more often clashes are run-time errors

Expand Down Expand Up @@ -121,7 +121,7 @@ Mutable Variant Record
Mutable Variant Record Example
--------------------------------

* Each object of :ada:`Person` has three fields, but it depends on :ada:`Group`
* Each object of :ada:`Person` has three components, but it depends on :ada:`Group`

.. code:: Ada

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Defining a Discriminated Record

* **Discriminant** controls behavior of the record
* Part of record definition
* Can be read as any other field
* Can be read as any other component

* But can only be modified by object assignment (sometimes)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Variant Records
What is a Variant Record?
---------------------------

* A :dfn:`variant record` uses the discriminant to determine which fields are currently accessible
* A :dfn:`variant record` uses the discriminant to determine which components are currently accessible

.. code:: Ada

Expand Down Expand Up @@ -133,7 +133,7 @@ Mutable Variant Record Example
end if;
Update (Pat);

* But you cannot change the discriminant like a regular field
* But you cannot change the discriminant like a regular component

.. code:: Ada

Expand Down Expand Up @@ -220,7 +220,7 @@ Quiz

.. container:: latex_environment footnotesize

* If you fix the compilation error (by changing the name of one of the :ada:`End_Point` fields), then
* If you fix the compilation error (by changing the name of one of the :ada:`End_Point` components), then

* You would get a warning on line 20 (because :ada:`A_Line` is constrained to be a :ada:`Line`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Simple Vector of Varying Length
Obj2 : Simple_Vstring := (0, (others => '+'));
Obj3 : Simple_Vstring;

* Issue - Operations need to consider :ada:`Last` field
* Issue - Operations need to consider :ada:`Last` component

* :ada:`Obj1 = Obj2` will be false
* Can redefine :ada:`=` to be something like
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Passing Records Between Ada and C
.. code:: C

struct Struct_T {
int Field1;
char Field2;
float Field3;
int Component1;
char Component2;
float Component3;
};

int DoSomething (struct Struct_T);
Expand All @@ -32,9 +32,9 @@ Building a C-Compatible Record
.. code:: Ada

type Struct_T is record
Field1 : Interfaces.C.int;
Field2 : Interfaces.C.char;
Field3 : Interfaces.C.C_Float;
Component1 : Interfaces.C.int;
Component2 : Interfaces.C.char;
Component3 : Interfaces.C.C_Float;
end record;

* We use types from :ada:`Interfaces.C` to map directly to the C types
Expand All @@ -46,9 +46,9 @@ Building a C-Compatible Record
.. code:: Ada

type Struct_T is record
Field1 : Interfaces.C.int;
Field2 : Interfaces.C.char;
Field3 : Interfaces.C.C_Float;
Component1 : Interfaces.C.int;
Component2 : Interfaces.C.char;
Component3 : Interfaces.C.C_Float;
end record with Convention => C_Pass_By_Copy;

-------------------------
Expand All @@ -64,9 +64,9 @@ Mapping Ada to C Unions
.. code:: C

union Union_T {
int Field1;
char Field2;
float Field3;
int Component1;
char Component2;
float Component3;
};

* By using a discriminant record and adding aspect :ada:`Unchecked_Union`
Expand All @@ -75,9 +75,9 @@ Mapping Ada to C Unions

type C_Union_T (View : natural := 0) is record
case View is
when 0 => Field1 : Interfaces.C.int;
when 1 => Field2 : Interfaces.C.char;
when 2 => Field3 : Interfaces.C.C_Float;
when 0 => Component1 : Interfaces.C.int;
when 1 => Component2 : Interfaces.C.char;
when 2 => Component3 : Interfaces.C.C_Float;
when others => null;
end case;
end record with Convention => C_Pass_By_Copy,
Expand All @@ -92,9 +92,9 @@ Quiz
.. code:: C

union Union_T {
struct Record_T field1;
char field2[11];
float field3;
struct Record_T component1;
char component2[11];
float component3;
};

.. code:: Ada
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Properties of Discriminated Record Types
* Rules

- Case choices for variants must partition possible values for discriminant
- Field names must be unique across all variants
- Component names must be unique across all variants

* Style

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ What To Import
with A;
package B is
type Something is record
Field : A.Something;
Component : A.Something;
end record;
end B;

with B; -- no "with" of A
procedure Foo is
X : B.Something;
begin
X.Field := ...
X.Component := ...

Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,10 @@ Quiz

Which component(s) is (are) legal?

A. ``Field_A : Integer := Private_T'Pos (Private_T'First);``
B. ``Field_B : Private_T := null;``
C. ``Field_C : Private_T := 0;``
D. :answermono:`Field_D : Integer := Private_T'Size;`
A. ``Component_A : Integer := Private_T'Pos (Private_T'First);``
B. ``Component_B : Private_T := null;``
C. ``Component_C : Private_T := 0;``
D. :answermono:`Component_D : Integer := Private_T'Size;`

.. code:: Ada

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,16 @@ Quiz
type P2_T is private;
private
type L1_T is limited record
Field : Integer;
Component : Integer;
end record;
type L2_T is record
Field : Integer;
Component : Integer;
end record;
type P1_T is limited record
Field : L1_T;
Component : L1_T;
end record;
type P2_T is record
Field : L2_T;
Component : L2_T;
end record;
end P;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ Incomplete Types
type Unconstrained_Record_Access_T is access all Unconstrained_Record_T;

type Some_Record_T is record
Field : String (1 .. 10);
Component : String (1 .. 10);
end record;

type Unconstrained_Record_T (Size : Index_T) is record
Field : String (1 .. Size);
Component : String (1 .. Size);
end record;

--------------------
Expand All @@ -56,14 +56,14 @@ Linked List in Ada
.. code:: Ada

type Some_Record_T is record
Field : String (1 .. 10);
Next : Some_Record_Access_T;
Component : String (1 .. 10);
Next : Some_Record_Access_T;
end record;

type Unconstrained_Record_T (Size : Index_T) is record
Field : String (1 .. Size);
Next : Unconstrained_Record_Access_T;
Previous : Unconstrained_Record_Access_T;
Component : String (1 .. Size);
Next : Unconstrained_Record_Access_T;
Previous : Unconstrained_Record_Access_T;
end record;

------------------------
Expand All @@ -78,8 +78,8 @@ Simplistic Linked List
type Some_Record_T;
type Some_Record_Access_T is access all Some_Record_T;
type Some_Record_T is record
Field : String (1 .. 10);
Next : Some_Record_Access_T;
Component : String (1 .. 10);
Next : Some_Record_Access_T;
end record;

Head : Some_Record_Access_T := null;
Expand All @@ -105,7 +105,7 @@ Simplistic Linked List

Put_Line ("List");
while Head /= null loop
Put_Line (" " & Head.Field);
Put_Line (" " & Head.Component);
Head := Head.Next;
end loop;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ And the following declarations:
.. code:: Ada

type Record_T is record
Field : Integer;
Component : Integer;
end record;
function Add (L : Record_T; I : Integer) return Record_T is
((Field => L.Field + I))
((Component => L.Component + I))
function Weird (L : Integer; R : Integer) return Integer is (0);

Which of the following instantiation(s) is/are **not** legal?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Freeze Point for Tagged Types
Tagged Aggregate
------------------

* At initialization, all fields (including **inherited**) must have a **value**
* At initialization, all components (including **inherited**) must have a **value**

.. code:: Ada

Expand All @@ -113,7 +113,7 @@ Tagged Aggregate
* For **private types** use :dfn:`aggregate extension`

- Copy of a parent instance
- Use :ada:`with null record` absent new fields
- Use :ada:`with null record` absent new components

.. code:: Ada

Expand Down Expand Up @@ -199,26 +199,26 @@ Which code block(s) is (are) legal?
.. container:: column

A. | ``type A1 is record``
| ``Field1 : Integer;``
| ``Component1 : Integer;``
| ``end record;``
| ``type A2 is new A1 with null record;``
B. | :answermono:`type B1 is tagged record`
| :answermono:`Field2 : Integer;`
| :answermono:`Component2 : Integer;`
| :answermono:`end record;`
| :answermono:`type B2 is new B1 with record`
| :answermono:`Field2b : Integer;`
| :answermono:`Component2b : Integer;`
| :answermono:`end record;`

.. container:: column

C. | ``type C1 is tagged record``
| ``Field3 : Integer;``
| ``Component3 : Integer;``
| ``end record;``
| ``type C2 is new C1 with record``
| ``Field3 : Integer;``
| ``Component3 : Integer;``
| ``end record;``
D. | ``type D1 is tagged record``
| ``Field1 : Integer;``
| ``Component1 : Integer;``
| ``end record;``
| ``type D2 is new D1;``

Expand Down
Loading