Skip to content

Commit 66f8128

Browse files
committed
fixed destructor syntax
1 parent 8b23122 commit 66f8128

File tree

1 file changed

+6
-35
lines changed

1 file changed

+6
-35
lines changed

features/rfc-oop-destructors.rst

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,18 @@ Guide-level explanation
1212
=======================
1313

1414
Record, tagged records and class records can declare destructors. The
15-
destructor is identifed by the `Destructor` attribute, e.g.:
15+
destructor is identifed by the `<type>'Destructor` attribute, e.g.:
1616

1717
.. code-block:: ada
1818
1919
package P is
2020
type T is tagged null record;
21-
for T'Destructor use T_Destructor;
2221
23-
procedure T_Destructor (Self : in out T);
22+
procedure T'Destructor (Self : in out T);
2423
25-
type T2 is new T with null record
26-
with Destructor => T2_Destructor;
24+
type T2 is new T with null record;
2725
28-
procedure T2_Destructor (Self : in out T2);
26+
procedure T2'Destructor (Self : in out T2);
2927
end P;
3028
3129
The destructor expands into a Finalizable type, and the runtime semantics can
@@ -44,30 +42,6 @@ The expansion is meant to allow the following:
4442
qualifier. We deem that it would be confusing wrt. the auto call parent
4543
semantics.
4644

47-
.. attention:: The original example above was:
48-
49-
.. code-block:: ada
50-
51-
package P is
52-
type T is tagged null record;
53-
for T'Destructor use My_Destructor;
54-
55-
procedure My_Destructor (Self : in out T);
56-
57-
type T2 is new T with null record
58-
with Destructor => My_Destructor;
59-
60-
procedure My_Destructor (Self : in out T2);
61-
end P;
62-
63-
Which seems wrong whichever way you look at it because both destructors
64-
have the same name. Either you want to disallow overriding the destructor
65-
subprogram itself, either you want to allow overriding but disallow
66-
respecification of the aspect.
67-
68-
The question being, which seems more natural ? I would say that we want to
69-
forbid overriding the subprogram itself, and use the expansion shown below.
70-
7145
Here is a proposed expansion for the example above:
7246

7347
.. code-block:: ada
@@ -114,16 +88,13 @@ Reference-level explanation
11488
Name resolution rules
11589
---------------------
11690

117-
* The ``Destructor`` aspect expects a procedure with a single parameter of the
91+
* The ``Destructor`` attribute expects a procedure with a single parameter of the
11892
type on which the aspect is defined.
11993

12094
Legality rules
12195
--------------
12296

123-
* It is forbidden to override a procedure specified as a value for the
124-
`Destructor` aspect.
125-
126-
* The `Destructor` aspect can be re-specified for types derived from a type
97+
* The `Destructor` attribute can be re-specified for types derived from a type
12798
that has a `Destructor` aspect.
12899

129100
* The subprogram passed to the destructor aspect should have the ``in out``

0 commit comments

Comments
 (0)