comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Smart pointers and delegation
Date: Tue, 8 Aug 2017 08:27:15 +0200
Date: 2017-08-08T08:27:15+02:00	[thread overview]
Message-ID: <omblk3$svi$1@gioia.aioe.org> (raw)
In-Reply-To: omaq6r$r85$1@franka.jacob-sparre.dk

On 2017-08-08 00:39, Randy Brukardt wrote:
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
> news:om3vsc$jhk$1@gioia.aioe.org...

>> Let I want to pass R to an operation F of X. This should lock/unlock on
>> the way. I cannot do that without some third type.
> 
> Right. And that's a problem how? Helper types are quite common in ADTs.

Everything is wrong. Helper type indicates language design problem. Each 
and every type must reflect some entity in the problem space. Helper 
type, as the name suggests, reflects a language problem instead.

>> Implicit dereferencing semantically does the same. For each visible
>> operation of the target type it declares an anonymous operation of the
>> reference type that dereferences and then calls to the original operation.
> 
> I don't see this at all.

You do it with the eyes closed... (:-))

>> Smart pointers use the opposite approach. Pointers (the last one) outlive
>> the targets. If a container is built then out of smart pointers, e.g. it
>> keeps pointers to the elements. Alternatively, it can keep raw elements
>> and hold a reference to each. You access elements strictly through
>> pointers which need not to be disposed immediately. They can live as long
>> as necessary. It can be used in transactional schemes, e.g. cloning
>> elements for mutators if the reference count > 1 etc.
> 
> It's not really opposite, though, if you want to limit the lifetime of the
> reference (even if that limit is potentially a long time).

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.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

  reply	other threads:[~2017-08-08  6:27 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 [this message]
2017-08-09  0:27                 ` Randy Brukardt
2017-08-09  7:37                   ` Dmitry A. Kazakov
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