comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Getting the index for an element in mutually referencing containers
Date: Sun, 12 Mar 2017 18:42:30 +0100
Date: 2017-03-12T18:42:30+01:00	[thread overview]
Message-ID: <oa41a4$1ko5$1@gioia.aioe.org> (raw)
In-Reply-To: ly60jebg2v.fsf@pushface.org

On 2017-03-12 17:44, Simon Wright wrote:
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
>
>> On 2017-03-12 12:30, Simon Wright wrote:
>>> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
>>>
>>>> On 2017-03-11 22:46, Simon Wright wrote:
>>>
>>>>> Basically, I (Simon, now) am having trouble thinking of an
>>>>> application where reference counting would be an appropriate
>>>>> solution.
>>>>
>>>> As I said, in practice it is all cases when you would have a
>>>> container of mutable elements.
>>>
>>> I had some trouble understanding your point the first time, and
>>> skipped over it (sorry).
>>>
>>> What's the opposite of "mutable"? constant? because, if so, why
>>> wouldn't I use Update_Element?
>>
>> Yes, But it is almost never element update. Usually what you want is
>> to call some mutable operations on the element. The language does not
>> offer user-defined by-reference or copy-out-copy-in methods to element
>> access.
>
> with Ada.Containers.Vectors;
> package Mutable_Elements is
>    type Element is record

[...]

Your example uses access type in Reference_Type which was the point.

Issues to consider are:

1. Two useless Reference_Type type where there should be none, if Ada 
had references.

2. The case of long living multiple references for which Reference_Type 
is no solution.

The case #1 is compiler-managed implicit references or copies. The case 
#2 is user-managed referential helper types. Reference-counted objects 
serve both #1 and #2, being really necessary only for #2.

P.S. It is a pity that Implicit_Dereference type does not have proper 
interface to work with *any* type instead of discriminated records. This 
is design fault when the use case #2 was taken for #1.

P.P.S. Issues with inheritance upon derivation from the container type, 
from the element type, and from both not even mentioned.

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


  reply	other threads:[~2017-03-12 17:42 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-09 13:45 Getting the index for an element in mutually referencing containers Mart van de Wege
2017-03-09 15:25 ` Egil H H
2017-03-09 15:45   ` Mart van de Wege
2017-03-09 16:02     ` Mart van de Wege
2017-03-09 16:11     ` Egil H H
     [not found] ` <ly7f3xedp4.fsf@pushface.org>
     [not found]   ` <86k27xpikd.fsf@gaheris.avalon.lan>
     [not found]     ` <lywpbxc9my.fsf@pushface.org>
     [not found]       ` <86wpbxneuz.fsf@gaheris.avalon.lan>
     [not found]         ` <o9vcbp$t0t$1@franka.jacob-sparre.dk>
2017-03-11  6:45           ` Mart van de Wege
2017-03-11  8:40           ` Simon Wright
2017-03-11  8:58             ` Dmitry A. Kazakov
2017-03-11 11:21               ` Simon Wright
2017-03-11 14:18                 ` Dmitry A. Kazakov
2017-03-11 20:05                   ` Simon Wright
2017-03-11 20:52                     ` Dmitry A. Kazakov
2017-03-11 21:46                       ` Simon Wright
2017-03-11 22:37                         ` Niklas Holsti
2017-03-12  8:22                           ` Simon Wright
2017-03-12  9:38                             ` G.B.
2017-03-12 11:21                               ` Simon Wright
2017-03-13 10:29                             ` Alejandro R. Mosteo
2017-03-12  8:20                         ` Dmitry A. Kazakov
2017-03-12 11:30                           ` Simon Wright
2017-03-12 11:55                             ` Dmitry A. Kazakov
2017-03-12 16:44                               ` Simon Wright
2017-03-12 17:42                                 ` Dmitry A. Kazakov [this message]
2017-03-13 19:55                                   ` Randy Brukardt
2017-03-13 20:53                                     ` Dmitry A. Kazakov
2017-03-14 20:40                                       ` Randy Brukardt
2017-03-15  8:44                                         ` Dmitry A. Kazakov
2017-03-15 20:12                                           ` Randy Brukardt
2017-03-16  2:59                                             ` Paul Rubin
2017-03-16  9:04                                             ` Dmitry A. Kazakov
2017-03-13 23:25                                   ` Simon Wright
2017-03-14  8:25                                     ` Dmitry A. Kazakov
2017-03-12  1:36             ` 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