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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,616091a85ff150f1 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-12-05 07:16:47 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news-FFM2.ecrc.net!news.iks-jena.de!lutz From: lutz@iks-jena.de (Lutz Donnerhacke) Newsgroups: comp.lang.ada Subject: Re: Ada 200X Assertions Date: Wed, 5 Dec 2001 15:16:45 +0000 (UTC) Organization: IKS GmbH Jena Message-ID: References: <3C0C48BE.3B20F04E@adaworks.com> NNTP-Posting-Host: taranis.iks-jena.de X-Trace: branwen.iks-jena.de 1007565405 21222 217.17.192.37 (5 Dec 2001 15:16:45 GMT) X-Complaints-To: usenet@iks-jena.de NNTP-Posting-Date: Wed, 5 Dec 2001 15:16:45 +0000 (UTC) User-Agent: slrn/0.9.6.3 (Linux) Xref: archiver1.google.com comp.lang.ada:17447 Date: 2001-12-05T15:16:45+00:00 List-Id: * Matthew Heaney wrote: >"Lutz Donnerhacke" wrote in message >> Problem 1: Pointer of component => Pointer to aggregate [...] >> Of course this Conversion may return a Pointer to an invalid aggregate. > >What on Earth are you trying to do here? I've a list of degenerated compound instantiations for which only a single component is relevant. More than this, this same fixed component is shared by multiple compound instantiations. Typical example 1: A common termination node of linked lists. Typical example 2: A head node of a linked list contains a next pointer which should be handled exactly as the next pointer of the real list nodes, but no payload at all. It would be fine to generate a pointer from this component to a 'virtual' aggregate of the given type. Example: struct node { ... data ... struct node * next; } struct head { struct node * next; } struct head h; h.next = &h - sizeof (node) + sizeof (head); AdaYY should be able to represent such structures. >Of course the language already allows you to move from a pointer to >component to a pointer to aggregate: just use an access discriminant. This generates a completely different structure. > procedure Iterate (List : in out List_Type) is > Item : List_Item_Class_Access := List.Head; > begin > while Item /= null loop > Process (Item); > Item := Item.Next; > end loop; > end; and end in a different algorithm: procedure Iterate (List : in out List_Type) is Item : List_Item_Class_Access := List.Next; begin while Item /= Item.Next loop Process (Item); Item := Item.Next; end loop; end;