comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Smart pointers and delegation
Date: Wed, 2 Aug 2017 08:20:05 +0200
Date: 2017-08-02T08:20:05+02:00	[thread overview]
Message-ID: <olrqum$1t4b$1@gioia.aioe.org> (raw)
In-Reply-To: olr1ie$ejl$1@franka.jacob-sparre.dk

On 2017-08-02 01:06, Randy Brukardt wrote:
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
> news:olplb6$jq0$1@gioia.aioe.org...
>> I would like to discuss delegation proposal as a replacement for crude,
>> inside out Implicit_Dereference aspect.
> 
> There never are "replacements", as existing Ada code has to work.

It is not replacement in that sense. Replacement here applies to the 
"use case", i.e. creating subtypes. Implicit dereferencing effectively 
makes pointer a "subtype" of the target type.

> And as usual, you didn't explain the problem that you're trying to solve.

The problem is subtyping and automated creation of wrappers to implement 
"trivial" operations. The method is delegation. Examples are presented.

> Implicit_Dereference was designed so a programmer can get control just
> before and just after the use of a dereference.

Certainly not. There is no prologue or epilogue hooks, just one ugly 
access type exposed. Should have been any function or expression 
instead. But it is irrelevant because there is a lot of unwanted and 
damaging stuff that comes with implicit dereferencing making it unusable 
for the use cases in question. Like exposing the target type, which is 
no-no for handle/proxy types. Like making reference objects indefinite etc.

> Implicit_Dereference very much matches the Ada model of "hooks" into
> language-defined operations (much like Adjust and Finalize allow
> user-defined operations to be associated with an assignment, rather than
> replacing it).

? Not even close. Adjust and Finalize are primitive operations, which 
was a horrific design choice, but nevertheless. Implicit dereference is 
not an operation, not even a body.

> The main intended use of this feature was to manage the lifetime of accessed
> entities, such as a persistent store, without requiring copies of the
> contained data (which might be large).

Copies are very essential in many cases, e.g. an external reference to a 
database table row etc. It is up to the programmer to define the semantics.

> Your proposal doesn't meet this particular need, because there is no way to
> tell when the program is finished with a function result.

I don't understand what you mean. The proposal considers exclusively how 
to generate bodies of normal primitive operations. All current rules 
apply to them, no any new rules needed.

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

  reply	other threads:[~2017-08-02  6:20 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 [this message]
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
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