comp.lang.ada
 help / color / mirror / Atom feed
From: lutz@iks-jena.de (Lutz Donnerhacke)
Subject: Re: Ada 200X Assertions
Date: Wed, 5 Dec 2001 15:16:45 +0000 (UTC)
Date: 2001-12-05T15:16:45+00:00	[thread overview]
Message-ID: <slrna0seip.kq.lutz@taranis.iks-jena.de> (raw)
In-Reply-To: u0q6368mkken84@corp.supernews.com

* Matthew Heaney wrote:
>"Lutz Donnerhacke" <lutz@iks-jena.de> 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;



  reply	other threads:[~2001-12-05 15:16 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-12-04  3:53 Ada 200X Assertions Richard Riehle
2001-12-04  8:54 ` Lutz Donnerhacke
2001-12-04 17:09   ` Robert Dewar
2001-12-05 14:34     ` Lutz Donnerhacke
2001-12-04 18:43   ` Matthew Heaney
2001-12-05 15:16     ` Lutz Donnerhacke [this message]
2001-12-05 18:40       ` Matthew Heaney
2001-12-05 19:25         ` Matthew Heaney
2001-12-05 19:36         ` Lutz Donnerhacke
2001-12-05 22:00           ` Mark Lundquist
2001-12-05 22:49             ` Matthew Heaney
2001-12-06  5:04               ` Mixins (was Re: Ada 200X Assertions) Mark Lundquist
2001-12-05 19:57       ` Access discriminants " Mark Lundquist
2001-12-05 21:30       ` Ada 200X Assertions Matthew Heaney
2001-12-05 21:32         ` Lutz Donnerhacke
2001-12-17  6:43       ` David Thompson
2001-12-17  8:55         ` Lutz Donnerhacke
2001-12-04 19:10 ` Randy Brukardt
2001-12-04 21:21   ` Ehud Lamm
2001-12-06  3:55     ` Richard Riehle
2001-12-06  9:41       ` Rod Chapman
2001-12-07 22:51     ` Mark Lundquist
2001-12-05  9:43 ` Volkert
replies disabled

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