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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Smart pointers and delegation Date: Wed, 9 Aug 2017 09:37:01 +0200 Organization: Aioe.org NNTP Server Message-ID: References: NNTP-Posting-Host: MajGvm9MbNtGBKE7r8NgYA.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:47657 Date: 2017-08-09T09:37:01+02:00 List-Id: On 2017-08-09 02:27, Randy Brukardt wrote: > "Dmitry A. Kazakov" wrote in message > news:omblk3$svi$1@gioia.aioe.org... >> Why would I want this, if the reference manages the object? The cardinal >> difference is between object-managed references and reference-managed >> objects. The former has a very limited use and would prefer to have all of >> them built-in. > > In that case, you definitely need to know precisely when the reference dies, > so you can "manage the object". Right. That is the advantage of the approach. Reference's life-time is better defined than the object's one. E.g. references can be scoped when the object cannot. Or, more importantly, when the object must stay hidden or is inaccessible like system resource or remote objects. > If you have a lifetime leak (such as any > normal access type does), then you can't do that management safely. It happens when references are components of other objects and/or have circular dependencies. Therefore strong and weak references go. > The pattern of the intended use-case of Implicit_Dereference does exactly this. It cannot replace smart pointer, because it does not manage the object. So the question is whether implicit dereference can be a part of smart pointer: target <-- smart pointer with implicit dereference This does not work for multiple reasons either. So the solution could only be ugly heavy-weighted: target <-- smart pointer || | || | operation to produce helper object || V target <-- helper object with implicit dereference This has no advantages whatsoever. Ergo, implicit dereference has no use for smart pointers. P.S. This is what happens with solutions of "real" problems... -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de