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: Mon, 10 Aug 2020 10:57:44 +0200	[thread overview]
Message-ID: <rgr267$1o1n$1@gioia.aioe.org> (raw)
In-Reply-To: rgq504$4fc$1@franka.jacob-sparre.dk

On 10/08/2020 02:39, Randy Brukardt wrote:
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
> news:rfv3gf$1bbo$1@gioia.aioe.org...

>> I don't want the compiler deciding where Q is allocated, especially
>> because this could break things:
>>
>> 1. Large object moved to the stack
> 
> The compiler is buggy IMHO if this breaks something. Any compiler has to be
> able to deal with objects that exceed the maximum stack frame, and move
> those to somewhere that they will fit (or reject completely).
> 
> Yes, most compilers are buggy this way (including mine in a few cases). So
> what?
> 
>> 2. Lock-free code starting using heap lock when moved from the stack.
> 
> Expecting a compiler not to use the heap is silly in any case (outside of
> the No_Heap restriction - use that in Janus/Ada and the compiler refuses to
> do anything outside of elementary types). The compiler is supposed to be
> making the programmer's life easier, not adding new hurdles.
> 
>> 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.
> 
> That's the idea of such mechanisms. If you really need control, you do not
> use these abstractions and instead write the stuff yourself explicitly using
> access types and the like.

Right, that is my take on the proposal. If I am ready to compromise on 
#1 and #2, I can use an abstraction hiding pool access. Otherwise I want 
a language construct being more safe than raw access types.

> Otherwise, you use containers and unbounded strings, and they do what they
> do.

No, from the abstraction point of view they do not. They indeed abstract 
the memory allocation aspect, but they do that at the cost of 
*everything* else. Unbounded_String is no string anymore. Container is 
neither array nor record type. Unbounded_String must be converted forth 
and back. For containers I must use ugly hacks like iterators to make 
them resemble arrays and records introducing whole levels of complexity 
to fight through every time the compiler or I miss something.

In most cases I prefer to keep a clear array or record interface at the 
expense of manual memory management.

> There's no free lunch.

I think with a better type system there could be a whole banquet. (:-))

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

  reply	other threads:[~2020-08-10  8:57 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
2020-08-10  0:39                   ` Randy Brukardt
2020-08-10  8:57                     ` Dmitry A. Kazakov [this message]
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