Skip to content
Merged
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
27 changes: 27 additions & 0 deletions courses/fundamentals_of_ada/adv_260_controlled_types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,33 @@ Unbounded String Implementation
end Adjust;
end Unbounded_String_Pkg;

------------------
Finalizable Aspect
------------------

* Uses the GNAT-specific :ada:`with Finalizable` aspect

.. code:: Ada

type Ctrl is record
Id : Natural := 0;
end record
with Finalizable => (Initialize => Initialize,
Adjust => Adjust,
Finalize => Finalize,
Relaxed_Finalization => True);

procedure Adjust (Obj : in out Ctrl);
procedure Finalize (Obj : in out Ctrl);
procedure Initialize (Obj : in out Ctrl);

* :ada:`Initialize`, :ada:`Adjust` same definition as previously
* :ada:`Finalize` has the :ada:`No_Raise` aspect: it cannot raise exceptions
* :ada:`Relaxed_Finalization`

* Performance on-par with C++'s destructor
* No automatic finalization of **heap-allocated** objects

========
Lab
========
Expand Down
Loading