comp.lang.ada
 help / color / mirror / Atom feed
From: "James S. Rogers" <jimmaureenrogers@worldnet.att.net>
Subject: Re: for x'address or variant
Date: Sun, 20 Apr 2003 14:05:48 GMT
Date: 2003-04-20T14:05:48+00:00	[thread overview]
Message-ID: <0Pxoa.69950$ja4.4649479@bgtnsc05-news.ops.worldnet.att.net> (raw)
In-Reply-To: b7u1jh$p6k$1@news.onet.pl

"kat-Zygfryd" <6667@wp.pl> wrote in message
news:b7u1jh$p6k$1@news.onet.pl...
> I have a tiny problem, I want to have a structure:
> type P is access X;
> type X is record
>     next: array(1..2) of P;
>     left: P;
>     right: P;
> end record;
> wherein the left component uses next(1)'address
> and right component uses next(2)'address,
> unfortunately "for x'address use" statements are
> not allowed within record declarations, and
> variant records don't allow me to access both
> next and left/right exchangably. do you know a way
> to work this out?

You want a record that holds two values.
The problem is that you want each value aliased by
two fields.

My first question is "why". If next(1) will always be
the same as left, and next(2) will always be the same
as right, then what do you gain by having two names
for the same value in a single record?

What are you trying to achieve? I do not see how your
intended design is any better than

type P is access X;
type X is record
   left : P;
   right : P;
end record;

Of course, this simple design also reveals that X is a node
of a doubly linked list of nothing. In other words, the node
contains no data except its position in a list. Such a data
structure is generally useless.

Jim Rogers





  reply	other threads:[~2003-04-20 14:05 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-20 11:50 for x'address or variant kat-Zygfryd
2003-04-20 14:05 ` James S. Rogers [this message]
2003-04-20 15:17 ` Steve
2003-04-20 16:19 ` Nick Roberts
2003-04-20 16:57   ` kat-Zygfryd
2003-04-20 16:17     ` Simon Wright
2003-04-20 18:07       ` kat-Zygfryd
2003-04-20 19:39         ` Robert A Duff
2003-04-20 21:17           ` kat-Zygfryd
2003-04-21  2:25             ` John R. Strohm
2003-04-21 10:26               ` kat-Zygfryd
2003-04-21 12:59                 ` Robert A Duff
2003-04-21 16:29                   ` kat-Zygfryd
2003-04-21 17:25                     ` tmoran
2003-04-21 19:48                     ` Robert A Duff
2003-04-21 20:12                       ` kat-Zygfryd
2003-04-21 20:55                         ` Robert A Duff
2003-04-22 12:02                         ` John R. Strohm
replies disabled

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