From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3fc1c2283df835d5,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-30 04:31:03 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!news-FFM2.ecrc.net!news.iks-jena.de!not-for-mail From: Lutz Donnerhacke Newsgroups: comp.lang.ada Subject: Limited_Controlled types as 'out' arguments Date: Wed, 30 Jul 2003 11:31:03 +0000 (UTC) Organization: IKS GmbH Jena Message-ID: NNTP-Posting-Host: taranis.iks-jena.de X-Trace: branwen.iks-jena.de 1059564663 12670 217.17.192.37 (30 Jul 2003 11:31:03 GMT) X-Complaints-To: usenet@iks-jena.de NNTP-Posting-Date: Wed, 30 Jul 2003 11:31:03 +0000 (UTC) User-Agent: slrn/0.9.7.4 (Linux) Xref: archiver1.google.com comp.lang.ada:40994 Date: 2003-07-30T11:31:03+00:00 List-Id: I'm using an Limited_Controlled type as an 'out' parameter of a procedure. While programming this procedure in question, I wonder how to Finalize the object given as argument to the 'out' parameter. ------------------------------------------------------------------------ with Ada.Finalization; package t1 is type Test is new Ada.Finalization.Limited_Controlled with record a : Character; end record; procedure Initialize(o : in out Test); procedure Finalize(o : in out Test); procedure Copy(to : out Test; from : Test); end t1; ------------------------------------------------------------------------ with t1; use t1; procedure t is a, b, c : Test; begin Copy(a, b); Copy(a, c); end t; ------------------------------------------------------------------------ with Ada.Text_IO; use Ada.Text_IO; package body t1 is global : Character := '0'; procedure Initialize(o : in out Test) is begin o.a := global; Put_Line("Initializing " & o.a); global := Character'Succ(global); end Initialize; procedure Finalize(o : in out Test) is begin Put_Line("Finalizing " & o.a); end Finalize; procedure Copy(to : out Test; from : Test) is begin to.a := global; Put_Line("Copying " & from.a & " to " & to.a); global := Character'Succ(global); end Copy; end t1; ------------------------------------------------------------------------ This results in: Initializing 0 Initializing 1 Initializing 2 Copying 1 to 3 Copying 2 to 4 Finalizing 2 Finalizing 1 Finalizing 4 Clearly, the variable 0 and 3 are never finalized. How implement I this correctly (without refering to the rosen trick).