comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Proposal: Auto-allocation of Indefinite Objects
Date: Sat, 4 Apr 2020 10:31:35 +0200
Date: 2020-04-04T10:31:35+02:00	[thread overview]
Message-ID: <r69gl7$1ntr$1@gioia.aioe.org> (raw)
In-Reply-To: 94a54092-a56f-4a99-aaec-08dd611c8fd8@googlegroups.com

On 2020-04-04 00:48, Stephen Davies wrote:

> It is the 3rd reason that initially got me thinking about this.
> It seems excessive to have two versions of packages just because
> one version can say "Node.Item := New_Item;" but the other has to say
> "Node.Item_Ptr := new Element_Type'(New_Item);".

This is another issue, IMO. The language should support interface 
inheritance:

    type Node_Item_Inteface is ...;

    type Static_Node_Item is
       new Node_Item_Inteface with record ...

    type Dynamic_Node_Item is
       new Node_Item_Inteface with access Some_Implementation;

Implementation of an interface per access type.

> It's probably not a good idea for auto-allocation to be the default
> behaviour, so I suggest something like:
> 
>     type Node_Type is record
>        Item : new Element_Type;
>        Prev : Node_Ptr_Type;
>        Next : Node_Ptr_Type;
>     end record;
> 
> If Element_Type is a definite type in the instantiation then
> Node.Item will be a normal object of that type. Otherwise, it is
> implemented as a pointer but the code still treats it as an object.
> The target of the pointer is allocated on assignment of the object.
> The pointer cannot be copied to any other object. Assignments of the
> whole record will perform a deep-copy of the auto-allocated component.
> The target of the Node.Item pointer can be auto-deallocated when Node
> goes out of scope or is deallocated.
> 
> Ok, I've probably missed something obvious and have been wasting my
> time, but at least I've got plenty of time to waste at the moment.

This looks interesting to me. There is a huge number of cases I am using 
this schema, especially when Item is initialized once.

The major advantage is of course in having a plain String instead of 
Unbounded_String. No conversions, no space/time penalties. I refrain 
using Unbounded_String as much as possible.

Also there must be a possibility to specify the pool of Item. I 
frequently place things like Node_Type into an arena pool, soI want the 
string going there as well. Another case is marshaling such objects, so 
that the body of Item would not be left behind.

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

  parent reply	other threads:[~2020-04-04  8:31 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-03 22:48 Proposal: Auto-allocation of Indefinite Objects Stephen Davies
2020-04-03 23:45 ` Stephen Leake
2020-04-04 10:54   ` Jeffrey R. Carter
2020-04-04 20:55     ` Stephen Davies
2020-04-04  8:31 ` Dmitry A. Kazakov [this message]
2020-07-27  7:47 ` Yannick Moy
2020-07-27  9:21   ` J-P. Rosen
2020-07-27  9:49     ` Dmitry A. Kazakov
2020-07-27 17:48   ` Brian Drummond
2020-07-27 20:02     ` Dmitry A. Kazakov
2020-07-28 14:28       ` Brian Drummond
2020-07-28 14:59         ` Dmitry A. Kazakov
2020-07-29 15:33           ` Brian Drummond
2020-07-29 16:20             ` Dmitry A. Kazakov
2020-07-30 13:37               ` Stephen Davies
2020-07-30 14:23                 ` Dmitry A. Kazakov
2020-07-30 17:04               ` Brian Drummond
2020-07-30 18:28                 ` Dmitry A. Kazakov
2020-08-10  0:39                   ` Randy Brukardt
2020-08-10  8:57                     ` Dmitry A. Kazakov
2020-08-20  0:10                       ` Randy Brukardt
2020-08-20 17:49                         ` Dmitry A. Kazakov
2020-08-20 20:19                           ` Dennis Lee Bieber
2020-08-20 23:33                             ` Randy Brukardt
2020-08-21  6:45                               ` Dmitry A. Kazakov
2020-08-23  4:52                                 ` Randy Brukardt
2020-08-23 12:28                                   ` Dmitry A. Kazakov
2020-08-20 23:30                           ` Randy Brukardt
2020-08-21  6:46                             ` Dmitry A. Kazakov
2020-08-23  4:48                               ` Randy Brukardt
2020-08-23 12:29                                 ` Dmitry A. Kazakov
2020-08-10  0:31               ` Randy Brukardt
2020-08-10  8:58                 ` Dmitry A. Kazakov
2020-08-20  0:13                   ` Randy Brukardt
2020-08-20 17:49                     ` Dmitry A. Kazakov
2020-08-20 23:25                       ` Randy Brukardt
2020-08-21  7:08                         ` Dmitry A. Kazakov
2020-08-23  5:03                           ` Randy Brukardt
2020-08-23 12:28                             ` Dmitry A. Kazakov
2020-07-27 20:31     ` Jeffrey R. Carter
2020-07-31  9:25 ` Stephen Davies
2020-07-31 10:20   ` Dmitry A. Kazakov
2020-08-01 11:22     ` Stephen Davies
2020-08-01 12:58       ` Dmitry A. Kazakov
2020-08-01 20:35         ` Stephen Davies
2020-08-01 20:56           ` Dmitry A. Kazakov
2020-09-03  4:30 ` linda white
replies disabled

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