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 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Should weak counted reference be able to be strengthened? Date: Tue, 25 Nov 2014 09:36:37 +0100 Organization: cbb software GmbH Message-ID: <1xbl1kdcf9at5.1dfv4py4kvx0o.dlg@40tude.net> References: <7d9r3whe43z8$.1f2l3n5cz0zh0$.dlg@40tude.net> <1tlppwq452jbq$.d1y3trfego8b$.dlg@40tude.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: nyHeW7QjJmC1odUjK4LkDA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:23709 Date: 2014-11-25T09:36:37+01:00 List-Id: On Mon, 24 Nov 2014 16:15:10 -0600, Randy Brukardt wrote: > "Dmitry A. Kazakov" wrote in message > news:1tlppwq452jbq$.d1y3trfego8b$.dlg@40tude.net... >> On Fri, 21 Nov 2014 16:39:25 -0600, Randy Brukardt wrote: >> > ... >> [...] >>> The real question is whether there is a real need to have a long-lived >>> Strong_Reference. I would argue against such a thing, but I don't think >>> it is clearly an open-and-shut case. >> >> Sure, the only purpose of strong references is to be long-lived. > > But you (almost?) never need such a thing, at least not without access to > underlying object as well. Thus I suggested unifying the Accessor and the > Strong_Reference. Right. But I go one step further and hide target type altogether making only the reference visible. Actually, reference like an access type must inherit the target object's interface. The original Ada 83 design was right with regard to indexing and record member operations inherited by access types. It should have inherited everything including assignment. Access type assignment should have a different notation unless ":=" were specifically overridden. Especially because copying pointers is always dangerous. >>> Sure, but now you have an extra function with no real purpose. If you use >>> the accessor form, you don't need any way at all to get the pointer, you >>> always have access to it. >> >> Accessor is a whole type without purpose and all functions it has are >> without purpose as well. > > I was suggesting that "Accessor" actually be named "Strong_Reference"; I can > see no need for a separate Strong_Reference type. As such, there's no extra > type here. Instead, you have an extra function "Ptr" which serves no purpose > except an extra complication. :-) Ptr was needed to keep it Ada 95 compatible. An Ada 2005 design would hide the target object type altogether. type T_Interface is interface ... procedure Foo (X : T_Interface) is abstract; privately: type T is ... and T_Interface ... -- Object implementation overriding procedure Foo (X : T); publicly type T_Reference is ... and T_Interface with private; overriding procedure Foo (X : T_Reference); private type T_Ptr is access T; type T_Reference is ... and T_Interface with record Ptr : T_Ptr; end record; procedure Foo (X : T_Reference) is begin X.Ptr.Foo; -- Delegation end Foo; Instead of introducing "crazy beautiful" implicit dereference, Ada 2012 should have delegation support for the patterns like this. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de