From: "markww" <markww@gmail.com>
Subject: Re: how to import a package
Date: 5 Dec 2006 19:34:11 -0800
Date: 2006-12-05T19:34:11-08:00 [thread overview]
Message-ID: <1165376051.158320.95410@j44g2000cwa.googlegroups.com> (raw)
In-Reply-To: <1165374364.874225.237370@n67g2000cwd.googlegroups.com>
Hi Adam,
Thanks for your help. Now I've instantiated a list of my ppl records.
Right underneath the generic package definition I had:
Start : Node_Ptr;
Last : Node_Ptr;
but Node_Ptr is not visible. Is it no longer possible to have those two
variables declared like that?
Thanks,
Mark
Adam Beneschan wrote:
> markww wrote:
> > Hi,
> >
> > I have this snippet of code (from members here) which defines a generic
> > type:
> >
> > generic
> > type T is private;
> > package P is
> > type Node;
> > type Node_Ptr is access Node;
> > type Node is record
> > Data : T;
> > Prev_Rec : access Node; -- points to the next record or
> > null if none exists.
> > Next_Rec : access Node; -- points to the previous record or
> > null if none exists.
> > end record;
> > end P;
> >
> > Now my compiler (gnat) complains that Node, and Node_Ptr are not seen
> > by the rest of the application. Is this because they are scoped within
> > package P?
> >
> > If so, how do I 'import' the package? Right now I just stuck this at
> > the start of my main procedure:
>
> P is a generic package so you have to instantiate it. Something like:
>
> package Person_List is new P (T => Person_Rec);
>
> Now, Node and Node_Ptr are visible within Person_List, and the "Data"
> field in Person_List.Node will have type Person_Rec.
>
> There's no such thing as a "generic type" in Ada.
>
> -- Adam
next prev parent reply other threads:[~2006-12-06 3:34 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 [this message]
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
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