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 Path: g2news2.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!nuzba.szn.dk!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Making a nonlimited type controlled by means of a controlled component Date: Fri, 14 Aug 2009 17:21:39 -0500 Organization: Jacob Sparre Andersen Message-ID: References: <31bb0f0b-9655-4bda-81c3-e8f7855a1ee9@c14g2000yqm.googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1250288567 1979 69.95.181.76 (14 Aug 2009 22:22:47 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Fri, 14 Aug 2009 22:22:47 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5512 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 Xref: g2news2.google.com comp.lang.ada:7804 Date: 2009-08-14T17:21:39-05:00 List-Id: "Ludovic Brenta" wrote in message news:31bb0f0b-9655-4bda-81c3-e8f7855a1ee9@c14g2000yqm.googlegroups.com... ... > Randy, do you have an opinion on this, or should I raise the problem > with the ARG? I'm not sure. The problem is that the assignment ought to raise Constraint_Error, because the discriminants don't match, and the components are constrained: X := Y; -- Ought to raise Constraint_Error. X.C.Enclosing = X'Access Y.C.Enclosing = Y'Access But I'm not sure if the language actually requires making such a check (generally, implementations assume that the constraints on subcomponents have to be OK - whether the language says this or not I'm not sure). An implementation that changes the discriminant X.C.Enclosing is surely wrong (can't change a constrained discriminant!). But one could imagine just copying the contents without copying the discriminant. So there might be benefit of a comment in order to look at the issue in more detail. Randy. P.S. The original example was: 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; -- What happens here?? X.C.Enclosing must not be changed, right? Ludovic.Show (X); Ludovic.Show (Y); New_Line; end Brenta;