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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5c89acd494ea9116 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!news.teledata-fn.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Self pointer in limited record Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1183577468.034566.57830@n60g2000hse.googlegroups.com> <1188578849.187422.280620@50g2000hsm.googlegroups.com> <9fy1xoukz1e3$.h574sqmiauri$.dlg@40tude.net> <1189441670.293887.176810@g4g2000hsf.googlegroups.com> Date: Mon, 10 Sep 2007 21:00:15 +0200 Message-ID: NNTP-Posting-Date: 10 Sep 2007 20:59:33 CEST NNTP-Posting-Host: 59ff30a1.newsspool2.arcor-online.net X-Trace: DXC=:El@13??k4Lk:C4l9A;OcOA9EHlD;3YcB4Fo<]lROoRA<`=YMgDjhgBH0>9A95b?8N[6LHn;2LCVN[ On Mon, 10 Sep 2007 16:27:50 -0000, amado.alves@gmail.com wrote: > FWIW, the problem was the following. I am writing a library. I wanted > to provide a function to the user to allow him to specify the parent > of an object in a simple way e.g. > Parent_Object : Object := Lookup (Name = "foo foo"); > Object : Object := Create (Name => "bla bla", Parent => > Parent_Object); What happens when the parent gets finalized before its child? The point is that if you have a reference semantics, then probably Object must be a reference. So access Obkect'Class were a better design. If you want to hide references, then you should use smart pointers instead. > The idea was to have a clean profile like > Create (Name : String; Parent : Object); > instead of > Create (Name : String; Parent : access Object); > > Inside the function there is code like > New_Object.Parent := Parent.Self; -- (clean profile) > or > New_Object.Parent := Parent; -- ('dirty' profile) > > I am kind of redesigning the library now so these issues are yet in > flux. I why don't you use Ada.Finalization.Limited_Controlled? Copying linked objects is suspicious anyway. When you copy a parent what happens with its children? Limited_Controlled is always aliased and by-reference. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de