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: Thu, 30 Jul 2020 20:28:32 +0200	[thread overview]
Message-ID: <rfv3gf$1bbo$1@gioia.aioe.org> (raw)
In-Reply-To: rfuujk$hh2$1@dont-email.me

On 30/07/2020 19:04, Brian Drummond wrote:
> On Wed, 29 Jul 2020 18:20:24 +0200, Dmitry A. Kazakov wrote:
> 
>> On 29/07/2020 17:33, Brian Drummond wrote:
>>> On Tue, 28 Jul 2020 16:59:09 +0200, Dmitry A. Kazakov wrote:
>>
>>>>>       A constant String := "done";
>>>>>       Q : indefinite String;
>>>>>     ...
>>>>>       loop
>>>>>          Q := Get_Line; exit when Q = A;
>>>>>       end loop;
>>>>
>>>> I am not comfortable with the semantics of this and with possible
>>>> implications too. I would keep it simple.
>>>
>>> Interesting. Can you pin down some of that discomfort? It looks simple
>>> to me :
>>>
>>> "indefinite" indicates the size can vary (and the compiler knows
>>> whether it used the heap or stack), and in the absence of "aliased" we
>>> know there are no copies of the pointer (if heap).
>>
>> I don't like compiler relocating objects. If the pool is a stack (or
>> heap organized as a stack) it might be unable to do this.
> 
> Ah OK, I see it.
> 
> The compiler should be able to determine if (as in the loop above) the
> use of Q (the indefinite type) is equivalent to a Declare block (i.e. can
> be on the stack; new stack frame in each iteration; no relocation ever
> required) or not.

I don't want the compiler deciding where Q is allocated, especially 
because this could break things:

1. Large object moved to the stack

2. Lock-free code starting using heap lock when moved from the stack.

The mechanism should be transparent. I do not like Unbounded_String for 
many reasons. Fiddling with the heap is one of them. I do not know which 
heuristic it uses to reduce reallocation and how much extra memory it 
takes under which circumstances.

>> In general, there are two close but not equivalent objectives one is
>> handling indefinite components of records another is a transparent
>> holder object integrated into the language (without generic mess).
>>
>> Your use case is about the latter. My is rather the former.
> 
> If a record with even one indefinite component is an indefinite record,
> and therefore embedded in a transparent holder (I like that term), aren't
> they equivalent?

I don't understand this question.

>>> Honest question : Inconsistent with what?
>>> I suggested shallow copy just for simplicity, and for no (ahh) deeper
>>> reason. But again, I'm probably missing something.
>>
>> If you make a shallow copy of
>>
>>      type Node_Type is record
>>         Item : new Element_Type;
>>         Prev : Node_Ptr_Type; Next : Node_Ptr_Type;
>>      end record;
>>
>> you create a dangling pointer should the original node disappear. A deep
>> copy would create a new target for new Item.
> 
> You are using "new" to signify Item is indefinite, I think?
> 
> But the problem is that Prev,Next are copies of the original Prev,Next
> pointers, so if the original Node_Type is then freed, they are dangling?

They are supposed to be handled by the doubly-linked list 
infrastructure, e.g. Prev and Next pointing to the node itself is a 
precondition for freeing the node.

The problem is with the node contents.

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

  reply	other threads:[~2020-07-30 18:28 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
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 [this message]
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