From: Simon Wright <simon.j.wright@mac.com>
Subject: Re: how to import a package
Date: Mon, 11 Dec 2006 07:00:48 +0000
Date: 2006-12-11T07:00:48+00:00 [thread overview]
Message-ID: <m21wn6yl0f.fsf@grendel.local> (raw)
In-Reply-To: 1165817760.736164.218530@73g2000cwn.googlegroups.com
"markww" <markww@gmail.com> writes:
> Ok I still don't understand why this assignment is illegal though -
> here's a test I have:
>
> generic
> type T is private;
> package GenericNode is
> type Node;
> type Node_Ptr is access Node;
> type Node is record
> Data : T; -- the generic data we want to
> store in a node.
> Prev_Rec : access Node_Ptr; -- points to the next record or
> null if none exists.
> Next_Rec : access Node_Ptr; -- points to the previous
> record or null if none exists.
> end record;
> end GenericNode;
>
> now later...
>
> package gNode is new GenericNode(T => PERSON_REC);
> use gNode;
>
> function Test(whatever : INTEGER) return INTEGER is
> Temp : gNode.Node_Ptr;
> begin
> Temp := Temp.Next_Rec; -- no!!!!!!!!!!!!!!!!
> return 0;
> end Test;
>
> Why is the Temp assignment not possible? The compiler says: expected
> type Node_Ptr defined in genericnode.ads. But I have defined it as type
> Node_Ptr.
You've declared Next_Rec as *access* Note_Ptr. I think you meant to
declare it as just Node_Ptr.
struct node {
T data;
node** prev_rec; /* should be just node* ? */
node** next_rec;
};
Also, look at the way you've commented on Prev_Rec and Next_Rec. Aside
from the comments being the wrong way round, you say 'points to the
... record'. As written, it points to *a pointer to* the .. record.
next prev parent reply other threads:[~2006-12-11 7:00 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-06 2:14 how to import a package markww
2006-12-06 3:06 ` Adam Beneschan
2006-12-06 3:34 ` markww
2006-12-06 9:18 ` Simon Wright
2006-12-06 19:47 ` Jeffrey R. Carter
2006-12-06 23:56 ` markww
2006-12-07 1:18 ` Björn Persson
2006-12-07 1:26 ` Brian May
2006-12-07 4:14 ` markww
2006-12-07 4:40 ` Brian May
2006-12-07 9:32 ` Stuart
2006-12-07 11:21 ` Jean-Pierre Rosen
2006-12-11 6:16 ` markww
2006-12-11 6:50 ` markww
2006-12-11 9:40 ` Georg Bauhaus
2006-12-11 14:19 ` markww
2006-12-11 15:03 ` Dmitry A. Kazakov
2006-12-11 16:22 ` Adam Beneschan
2006-12-11 20:28 ` Jeffrey R. Carter
2006-12-12 3:19 ` markww
2006-12-12 3:31 ` Jeffrey R. Carter
2006-12-12 9:03 ` Stuart
2006-12-12 10:56 ` Georg Bauhaus
2006-12-11 7:00 ` Simon Wright [this message]
2006-12-07 4:06 ` Jeffrey R. Carter
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox