From: Brian May <bam@snoopy.apana.org.au>
Subject: Re: how to import a package
Date: Thu, 07 Dec 2006 15:40:57 +1100
Date: 2006-12-07T15:40:57+11:00 [thread overview]
Message-ID: <sa4veko5ndy.fsf@margay.local> (raw)
In-Reply-To: 1165464845.649851.312700@79g2000cws.googlegroups.com
>>>>> "markww" == markww <markww@gmail.com> writes:
markww> Ok so I moved the package into another file, compiled it separately,
markww> and it seems to import now. Looks like:
markww> package Node is new GenericNode(T => PERSON_REC);
markww> use Node;
markww> and now I can declare variables like:
markww> Start : Node.Node_Ptr;
markww> which is very excellent. Thanks for your help with that. I thought it
markww> would be smooth sailing now but I ran into one other minor problem
markww> related to this which I think is just a syntax problem. I've defined a
markww> function to count the # of nodes I have like:
markww> function GetRecordCount(Starting_Point : Node.Node_Ptr) return
markww> INTEGER is
markww> Temp : Node.Node_Ptr;
markww> nCount : INTEGER := 0;
markww> begin
markww> Temp := Starting_Point;
markww> if Temp = null then
markww> return 0;
markww> else
markww> loop
markww> nCount := nCount + 1;
markww> Temp := Temp.Next_Rec; // PROBLEM
markww> if Temp = null then
markww> return nCount;
markww> end if;
markww> end loop;
markww> end if;
markww> end GetRecordCount;
markww> but I get an error at line:
markww> Temp := Temp.Next_Rec;
markww> expected type "Node_Ptr" defined at genericnode.ads:9, instance at
markww> line 29
markww> do I need to use some special syntax to do that assignment? Next_Rec is
markww> of type Node_Ptr so I don't see why it's causing an error.
Going back in time, you said you defined Next_Rec as:
type Node;
type Node_Ptr is access Node;
type Node is record
Data : T;
Prev_Rec : access Node;
Next_Rec : access Node;
end record;
Note that "access Node" is not the same thing as "Node_Ptr".
From memory the first is an "anonymous access type", but my memory is
a bit rusty on this topic right now (Ada 2005 feature when used in a
record?).
I think you want to replace "access Node" with "Node_Ptr".
--
Brian May <bam@snoopy.apana.org.au>
next prev parent reply other threads:[~2006-12-07 4:40 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 [this message]
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
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