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!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!io.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Smart pointers and delegation Date: Thu, 10 Aug 2017 19:17:39 -0500 Organization: JSA Research & Innovation Message-ID: References: Injection-Date: Fri, 11 Aug 2017 00:17:40 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="29520"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: news.eternal-september.org comp.lang.ada:47686 Date: 2017-08-10T19:17:39-05:00 List-Id: "Dmitry A. Kazakov" wrote in message news:omh3iv$1flt$1@gioia.aioe.org... > On 2017-08-10 00:57, Randy Brukardt wrote: ... >> 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); But these are subtly different. The procedure form can only update the entire element at once. (Given the potentially large number of subcomponents, it would be impractical to implement a procedure for each one -- and if you want the compiler to do it, you'd have to be able to write - within the language - how that's done, which brings back the original question.) Specifically, if you write: A (I).C := Y; there isn't any translation using Set that would do the right thing. (Using an implicit temporary for the entire object would force extra copying, which would have performance and tasking implications - it would be outright wrong for volatile/atomic objects.) > 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. Not sure I see how a "smart pointer" would work in this context. I could imagine some sort of handle working if you don't need partial, in-place updates. To do that, you have to merge the object interface and the container interface; as I noted I sometimes have done designs that way, I just don't call the handle a "smart pointer". Randy.