From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!newsfeed0.kamp.net!newsfeed.kamp.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Generic Embedded List Nodes Date: Tue, 21 Jun 2016 21:54:26 +0300 Organization: Tidorum Ltd Message-ID: References: <66c14298-c62d-4f4b-b0c0-e969454f9334@googlegroups.com> <2e39857a-7121-476b-807a-d2bff1e598f4@googlegroups.com> <431af616-7df3-4e4d-9262-26ed68cb74c7@googlegroups.com> <037df2b8-b9c4-4447-87ee-cc89d7072b30@googlegroups.com> <15914c54-191c-4f37-b754-282855d1aeaf@googlegroups.com> <3e25c9a0-469c-4487-b78e-6f87434f87fa@googlegroups.com> <2e69ca6f-484c-4d58-b0fe-d17a744b1418@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net HGPT9+H2Yu6TyaRf7xfZvAeE2XG3T8tIABFNrMXYP1PvL6pOLc Cancel-Lock: sha1:jHAdy6GpYVOhroxHb0YIabnInSk= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 In-Reply-To: Xref: news.eternal-september.org comp.lang.ada:30860 Date: 2016-06-21T21:54:26+03:00 List-Id: 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? > Any derivation must be used sparingly in Ada which > does not have full multiple inheritance. Once you have spent the proper > parent type you won't get another one. Mixin-generics are a work-around, but can be practical, IMO. On the other hand, it seems the OP is in control of and defines the object types, so embedded link nodes can be added manually without using generics, just by deriving object-specific types with suitable access discriminants from a root "embedded-link-node" type. >> This would eliminate the address arithmetic, at the >> cost of increasing the size of the record by the sizes of the >> discriminants (not a great deal). > > The advantage of pool-based design is that no address arithmetic is > needed for object operations. The list element is access to the object > type. Address arithmetic is needed for list operations only. 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. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .