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: Thu, 10 Aug 2017 09:56:19 +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:47671 Date: 2017-08-10T09:56:19+02:00 List-Id: On 2017-08-10 00:57, Randy Brukardt wrote: > "Dmitry A. Kazakov" wrote in message > news:omee2p$145a$1@gioia.aioe.org... >> 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. > > I find this surprising. It works in the use-cases I've tried. (I haven't > tried a pure Smart-Pointer, although others have, since I prefer to include > such things in a larger abstract - like a container). It will have a discriminant, to start with. Smart pointer must be aggregation-friendly. >> 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. > > Even if true, the "real problem" however remains. If you can safely and > efficiently copy the designated object, then you have no need for > Implicit_Dereference. If you need "return-by-reference", though, you need > some special mechanism to do that. I don't want A (I) := X; taken literally. That is an abstraction inversion. I want it compiled into more useful Set (A, I, X); My design of containers is that I effectively put a reference in the form of a smart pointer into the container. I don't need return by reference because I return a smart pointer, which is definite and non-limited. I have no problem with life time because the reference holds the object. I less problems with concurrent updates because the reference has a count so that the update may deploy a transaction scheme. And I tend to hide the referenced object type from public interface to make it more safe. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de