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, 1 Aug 2020 14:58:06 +0200	[thread overview]
Message-ID: <rg3osu$m7k$1@gioia.aioe.org> (raw)
In-Reply-To: ce6e208d-f1d5-4416-af26-09a22e8a7172n@googlegroups.com

On 01/08/2020 13:22, Stephen Davies wrote:
> On Friday, 31 July 2020 at 11:20:09 UTC+1, Dmitry A. Kazakov wrote:
>> On 31/07/2020 11:25, Stephen Davies wrote:
>>> On Friday, 3 April 2020 at 23:48:43 UTC+1, Stephen Davies wrote:
>>> Perhaps a better way to think of this is as a discriminated record without
>>> an explicit discriminant? In which case maybe a different syntax than "new"
>>> would be appropriate?
>> That is right, but it would be a much larger problem to resolve than
>> your original proposal.
>> First, Ada lacks necessary discriminants ...
>> Second, Ada's object initialization process has no means to determine
>> discriminants...
>> Third, there is still the problem that task components do not work...
>> All in one, the crude work-around has always been an access type...
> 
> Maybe I'm missing something but my thought was maybe there is no
> need for a named discriminant, e.g.
> type Node_Type (<>) is record
>     Item : Element_Type;
>     Prev : Node_Ptr_Type;
>     Next : Node_Ptr_Type;
> end record;
> The rules for such records would be the same as for discriminated ones,
> except that instead of usages needing to provide values for discriminants,
> they would need to provide values for indefinite components.

1. There is no discriminants for cases when Item is T'Class.

2. You cannot get discriminant from the value in the case of Rosen 
trick. Consider Item being a task with the access to the actual node as 
its discriminant:

    type Node_Type;
    task type Worker (Node : not null access Node_Type) is ...;
    type Mode_Type is record
       Item : Worker (Node_Type'Unchecked_Access);
       Prev : Node_Ptr_Type;
       Next : Node_Ptr_Type;
    end record;

You cannot initialize Item because you cannot construct Worker without 
having the node. And you cannot have the node without having Item 
initialized.

3. Copying is involved. There should be none, especially for limited 
types. Limited returns are broken per construction and nothing could 
ever fix them.

-------------------------
If the only problem were to deduce discriminants from a value. We could 
leave Node_Type as-is and simply fix aggregates:

    type T (L : Natural) is record
       S : String (1..L);
       I : Integer;
    end record;

Why not to make this legal?

    X : T := ("hello!", 123); -- L is deduced from S

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

  reply	other threads:[~2020-08-01 12:58 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
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 [this message]
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