comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Smart pointers and delegation
Date: Wed, 9 Aug 2017 09:37:01 +0200
Date: 2017-08-09T09:37:01+02:00	[thread overview]
Message-ID: <omee2p$145a$1@gioia.aioe.org> (raw)
In-Reply-To: omdkt3$lqf$1@franka.jacob-sparre.dk

On 2017-08-09 02:27, Randy Brukardt wrote:
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> 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

  reply	other threads:[~2017-08-09  7:37 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-01 10:32 Smart pointers and delegation Dmitry A. Kazakov
2017-08-01 15:06 ` Dmitry A. Kazakov
2017-08-01 23:06 ` Randy Brukardt
2017-08-02  6:20   ` Dmitry A. Kazakov
2017-08-03  3:36     ` Randy Brukardt
2017-08-03  7:40       ` Dmitry A. Kazakov
2017-08-04 23:03         ` Randy Brukardt
2017-08-05  8:33           ` Dmitry A. Kazakov
2017-08-07 22:39             ` Randy Brukardt
2017-08-08  6:27               ` Dmitry A. Kazakov
2017-08-09  0:27                 ` Randy Brukardt
2017-08-09  7:37                   ` Dmitry A. Kazakov [this message]
2017-08-09 22:57                     ` Randy Brukardt
2017-08-10  7:56                       ` Dmitry A. Kazakov
2017-08-11  0:17                         ` Randy Brukardt
2017-08-11  6:43                           ` Dmitry A. Kazakov
2017-08-11 20:37                             ` Randy Brukardt
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox