From 186283a036154dc008290bd45f393da281fcc568 Mon Sep 17 00:00:00 2001 From: Ronan Desplanques Date: Thu, 13 Nov 2025 15:19:59 +0100 Subject: [PATCH] Tweak example in assigments RFC This changes the example code in the assignments RFC. The new code is more efficient since it removes a free+malloc pair per assignment, and the new behavior would be much more difficult to achieve with Standard Ada controlled types. --- features/rfc-oop-aggregates-and-assignments.rst | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/features/rfc-oop-aggregates-and-assignments.rst b/features/rfc-oop-aggregates-and-assignments.rst index 85d5832..a71d86f 100644 --- a/features/rfc-oop-aggregates-and-assignments.rst +++ b/features/rfc-oop-aggregates-and-assignments.rst @@ -151,8 +151,7 @@ needs to be maintained equal to the parents. procedure Root'Clone (Self : Root; To : in out Root) is begin - Free (To.A); - To.A := new Integer'(Self.A.all); + To.A.all := Self.A.all; end Root'Clone; procedure Root'Adjust (Self : in out Root; From : Root) is @@ -172,8 +171,7 @@ needs to be maintained equal to the parents. procedure Child'Clone (Self : Child; To : in out Child) is begin' Root (To) := Root (Self); - Free (To.B); - To.B := new Integer'(Self.B.all); + To.B.all := Self.B.all; end Child'Clone; procedure Child'Adjust (Self : in out Child; From : Root) is