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!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!inka.de!rz.uni-karlsruhe.de!news.belwue.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: Tue, 11 Sep 2007 11:38:22 +0200 Message-ID: NNTP-Posting-Date: 11 Sep 2007 11:33:11 CEST NNTP-Posting-Host: 5591f105.newsspool4.arcor-online.net X-Trace: DXC=C:?d0VffFcofF8a^:6>b7e4IUKkgb^i?3_B?S^Sh X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:1885 Date: 2007-09-11T11:33:11+02:00 List-Id: On Mon, 10 Sep 2007 22:12:47 -0500, Randy Brukardt wrote: > "Dmitry A. Kazakov" wrote in message > news:h9v0j8x5uuf3.puwqdmssdfn6$.dlg@40tude.net... >> 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. > > I disagree. Claw uses a design rather like the one proposed here. All of the > needed references are created inside of the Claw library, and managed there > (with Finalization and Adjust). For instance, if the parent object is > finalized, the child object is finalized first (that's necessary because > destroying a parent window also destroys any children). If a child window is > finalized, it is unlinked from any lists that it is in. What happens when somebody would create some of these objects on the stack? You argue for automatic collection, that is my point too. But I would go further and hide target objects behind handles to. That would eliminate "access." The language problem is though that there is no simple way to delegate operations from handle to the target object. It requires a lot of work. > I strongly believe that having explicit access types in a specification is > wrong. Because of limitations in Ada, they can't quite all be eliminated (no > "in out" parameters for functions, for instance), but I think they should > only be used if there is no viable alternative. (This opinion is not > universal.) Agreed. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de