comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Generic Embedded List Nodes
Date: Tue, 21 Jun 2016 21:54:18 +0200
Date: 2016-06-21T21:54:18+02:00	[thread overview]
Message-ID: <nkc61e$1ub0$1@gioia.aioe.org> (raw)
In-Reply-To: dstgr3Fe23kU1@mid.individual.net

On 2016-06-21 20:54, Niklas Holsti wrote:
> On 16-06-21 10:15 , Dmitry A. Kazakov wrote:
>> On 21/06/2016 07:52, Niklas Holsti wrote:
>>
>>> If you don't get the address arithmetic to work,
>>
>> There is a subtle difference between access and X'Address, but otherwise
>> address arithmetic works. E.g. I can instantiate my implementation of
>> linked lists with any type including unconstrained and non-tagged ones.
>>
>>> I believe that a set of
>>> mixin-generics could be used to add as many embedded Emb_Nodes to a
>>> tagged limited record, with access discriminants pointing to the
>>> containing record.
>>
>> Adding links afterwards is even worse than deriving objects from a
>> abstract list node.
>
> Why do you think so? For philosophical or practical reasons?

Practical reasons. If you derive from the list element base you cannot 
have scalar or other non-tagged objects as elements, but you still can 
have a class of elements. When you add links last, you cannot have a 
class, that in effect finalizes the list item.

> But your pool-based design restricts objects to be linked into at most
> one list. The OP said that an object can be placed in two or more lists
> at the same time, and apparently the number of such lists varies
> according to the type of the object, depending on the number of embedded
> list nodes within the object.
>
> The pool-based design can no doubt be extended to allow multiple lists,
> but it then becomes more complex.

It is no more complex. In fact my design is multiple lists from the 
start. Doubly-linked list is a specialization of.

BTW, a design based on inheritance requires multiple additive 
inheritance for lists. Ada does not have this even for interfaces. E.g.

    type Abstract_List_Item is abstract tagged record
       Next : not null access Abstract_List_Item'Class :=
                  Abstract_List_Item'Access;
       Previous : not null access Abstract_List_Item'Class :=
                  Abstract_List_Item'Access;
    end record;

    type My_List_Item is -- This is not Ada!
       new Abstract_List_Item as List_One
       or  Abstract_List_Item as List_Two with
    record
       X : Integer;
    end record;

Members and primitive operations are renamed to resolve name clashes.

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

  reply	other threads:[~2016-06-21 19:54 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-18 22:52 Generic Embedded List Nodes Warren
2016-06-18 23:40 ` Jeffrey R. Carter
2016-06-19  2:15   ` Warren
2016-06-19  3:04     ` Jeffrey R. Carter
2016-06-19  2:14 ` Jeremiah
2016-06-19  2:21   ` Warren
2016-06-19  2:50     ` Warren
2016-06-19  4:45       ` Simon Wright
2016-06-19 18:27         ` Warren
2016-06-19 19:04           ` Dmitry A. Kazakov
2016-06-19 20:13             ` Warren
2016-06-19 20:35               ` Dmitry A. Kazakov
2016-06-20  2:42                 ` Warren
2016-06-20  7:25                   ` Dmitry A. Kazakov
2016-06-20 12:26                     ` Warren
2016-06-20 19:33                       ` Niklas Holsti
2016-06-21  2:20                         ` Warren
2016-06-21  5:52                           ` Niklas Holsti
2016-06-21  7:15                             ` Dmitry A. Kazakov
2016-06-21 18:54                               ` Niklas Holsti
2016-06-21 19:54                                 ` Dmitry A. Kazakov [this message]
2016-06-21 10:31                             ` Warren
2016-06-21 17:13                               ` Jeffrey R. Carter
2016-06-21 18:56                                 ` Niklas Holsti
2016-06-21 20:13                                   ` Warren
2016-06-21 21:38                               ` Niklas Holsti
2016-06-23  2:12                                 ` Warren
2016-06-23  8:19                                   ` Niklas Holsti
2016-06-23 12:37                                     ` Warren
2016-06-23 15:36                                       ` Niklas Holsti
2016-06-24  1:55                                         ` Warren
2016-06-24 12:49                                         ` Warren
2016-06-25  5:50                                           ` Niklas Holsti
2016-06-26  1:36                                             ` Warren
2016-07-01 13:49                                             ` Warren
2016-07-01 16:28                                               ` Warren
2016-06-24 20:25                                         ` Warren
2016-06-22 13:01                               ` G.B.
2016-06-23  2:30                                 ` Warren
2016-06-20  6:08 ` Niklas Holsti
2016-06-20 12:20   ` Warren
2016-06-20 19:47 ` Shark8
2016-06-21  2:28   ` Warren
2016-06-21  7:21     ` Dmitry A. Kazakov
2016-06-21 10:32       ` Warren
2016-06-21 11:56         ` Dmitry A. Kazakov
2016-06-21 13:39           ` Warren
2016-06-21 14:04             ` Dmitry A. Kazakov
2016-06-23  0:37     ` Randy Brukardt
2016-06-23  2:25       ` Warren
2016-07-01 19:50 ` brbarkstrom
2016-07-02  1:55   ` Warren
replies disabled

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