Skip to content
Open
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
34 changes: 17 additions & 17 deletions features/rfc-oop-constructors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ For example:
procedure T2'Constructor (Self : in out T2; Some_Value : Integer);
end P;

As soon as a constructor exist, an objects cannot be created without calling one
As soon as a constructor exist, objects cannot be created without calling one
of the available constructors, omitting the self parameter. This call is made on
the object creation, using the type followed by 'Make and the
constructor parameters. When preceded by a `new` operator, it creates an
Expand All @@ -55,11 +55,11 @@ object on the heap. E.g:
In the case of objects containing other objects, innermost objects constructors
are called first, before their containing object.

The `'Make'` function is automatically generated by the compilers. It has
The `'Make'` function is automatically generated by the compiler. It has
the same parameters, default values and default expressions as the constructor
it calls, with the exception of the first parameter. T'Make is not intrinsic,
it has the same convention as a function of the same profile, and can be used
e.g. as a generic parameter or through a access to subprogram.
e.g. as a generic parameter or through an access to subprogram.

Note that constructors will be "scoped" in a future extension of the RFC, but
the scoping notation isn't strictly necessary to implement initial semantics.
Expand Down Expand Up @@ -127,15 +127,15 @@ field by field its additional components, calling component copy constructors if
necessary.

Note that, similar to the parameterless constructor, copy constructor may be
explicitely or implicitely called:
explicitly or implicitly called:

.. code-block:: ada

V1 : T; -- implicit parameterless constructor call
V2 : T := V1; -- implicit copy constructor call
V3 : T := T'Make (V1); -- explicit copy constructor call

Note that by-copy constructor are also called in assignments situations
Note that by-copy constructors are also called in assignments situations
(following the call to a destructor). e.g.:

.. code-block:: ada
Expand All @@ -153,7 +153,7 @@ Super Constructor Call

By default, the parent constructor called is the parameterless constructor.
A parametric constructor can be called instead by using the ``Super`` aspect
in the constuctor body, For example:
in the constructor body. For example:

.. code-block:: ada

Expand Down Expand Up @@ -189,7 +189,7 @@ Note that the constructor of an abstract type can be called here, for example:
end Child'Constructor;

When valuating values in the Super aspect, the object under construction does
not exit yet. It is illegal to refer to its parameter in the aspect.
not exist yet. It is illegal to refer to its parameter in the aspect.

Initialization Lists
--------------------
Expand Down Expand Up @@ -283,7 +283,7 @@ initialized as described at declaration time. For example:
V2 : C := C'Make ("ALTERNATE A"); -- Will print ALTERNATE A, B FROM RECORD

Note for implementers - the objective of the semantic above is to make
initialization as efficient as possible and to avoid undecessary processing.
initialization as efficient as possible and to avoid unnecessary processing.
Conceptually, a developer would expect to have a specific initialization
procedure generated for each constructor (or maybe, have the initialization
directly expanded in the constructor).
Expand Down Expand Up @@ -507,8 +507,8 @@ of a discriminant other than by valuating it in a constructor. However, it
remains possible to constrain a subtype to be of a certain discriminant type.

For simple record types, this is done either by creating a subtype or by
providing a distriminant constrain at variable or component declaration. This
cannot however be used to create a value. For exmample:
providing a discriminant constraint at variable or component declaration. This
cannot however be used to create a value. For example:

.. code-block:: ada

Expand Down Expand Up @@ -556,7 +556,7 @@ Constructors and Type Predicates

Type predicates are meant to check the consistency of a type. In the context
of a type that has constructor, the consistency is expected to be true when
exiting the constructor. In particular, the initializion list is not expected
exiting the constructor. In particular, the initialization list is not expected
to create a predicate-valid type - predicates will only be checked after the
constructor has been processed.

Expand All @@ -566,7 +566,7 @@ Constructors Presence Guarantees
Constructors are not inherited. This means that a constructor for a given class
may not exist for its child.

By default, a class provide a parameterless constructor, on top of the copy
By default, a class provides a parameterless constructor, on top of the copy
constructor. This parameterless constructor is removed as soon as explicit
constructors are provided. For example:

Expand Down Expand Up @@ -674,7 +674,7 @@ Note that the notation:
type T1 is tagged private;

Accept both by-constructors and non-by constructor types. However,
by-constructor types would need to provide a parametelress constructor and a
by-constructor types would need to provide a parameterless constructor and a
copy constructor to be accepted as formal parameters.

Removing Constructors from Public View
Expand Down Expand Up @@ -725,11 +725,11 @@ Initialization
--------------

In certain situations, it's important to know if an object is considered
initialized. For example, this can clarify wether passing a value of such object
initialized. For example, this can clarify whether passing a value of such object
may lead to errors.

An object value in a constructor is considered initialized once the `Super` and
`Initialze` aspects have been computed. Formally, the role of the constructor
`Initialize` aspects have been computed. Formally, the role of the constructor
is to establish further properties than the initialization.

Reference-level explanation
Expand All @@ -756,7 +756,7 @@ Why do we have a Constructor as a Procedure and not a Function?

While explicit calls to a constructor are made through a function call `'Make`,
declaring a constructor is done through a procedure declaration, which might
look suprising. The overall rationale is that the constructed object must
look surprising. The overall rationale is that the constructed object must
be allocated (and sometimes even partially initialized) before any constructor
operation. The discriminants may need to be valuated, the super constructor
must be called. In some cases, the object memory is already allocated (think
Expand Down Expand Up @@ -936,7 +936,7 @@ Consider the following hierarchy:

Child does not have any discriminant. Root discriminant is set by its own
constructor. There is currently no syntax allowing to subtype Child and provide
a constrain to its discriminant.
a constraint to its discriminant.

An extension of the simple record syntax would be to be able to allow to refer
to parent discriminants in the constraint of a child type, so that one could
Expand Down