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-Thread: a07f3367d7,3ef3e78eacf6f938 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!a7g2000yqk.googlegroups.com!not-for-mail From: AdaMagica Newsgroups: comp.lang.ada Subject: Re: A few Ada questions Date: Fri, 24 Jul 2009 02:07:34 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: 91.13.200.21 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1248426454 17975 127.0.0.1 (24 Jul 2009 09:07:34 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 24 Jul 2009 09:07:34 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: a7g2000yqk.googlegroups.com; posting-host=91.13.200.21; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:7310 Date: 2009-07-24T02:07:34-07:00 List-Id: Hu Ludovic, that's dangerous what you proposed: ----------------------------------- private with Ada.Finalization; package Ludovic is type T is private; -- primitive operations here procedure Show (X: in T); private type Controller (Enclosing: access T) is new Ada.Finalization.Controlled with null record; overriding procedure Initialize (This: in out Controller); overriding procedure Adjust (This: in out Controller); overriding procedure Finalize (This: in out Controller); type T is record -- note: untagged record C: Controller (Enclosing => T'Access); I: Integer; end record; end Ludovic; with Ada.Text_IO; use Ada.Text_IO; package body Ludovic is I: Integer := 0; overriding procedure Initialize (This: in out Controller) is begin I := I + 1; This.Enclosing.I := I; end Initialize; overriding procedure Adjust (This: in out Controller) is begin This.Enclosing.I := This.Enclosing.I + 1; end Adjust; overriding procedure Finalize (This: in out Controller) is begin null; end Finalize; procedure Show (X: in T) is begin Put_Line (Integer'Image (X.I) & Integer'Image (X.C.Enclosing.I)); end Show; end Ludovic; with Ada.Text_IO; use Ada.Text_IO; with Ludovic; procedure Brenta is X, Y: Ludovic.T; begin Ludovic.Show (X); Ludovic.Show (Y); New_Line; X := Y; Ludovic.Show (X); -- X.C points to Y - that's surely not what you want. Ludovic.Show (Y); New_Line; end Brenta;