From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,910a48a538936849 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!n67g2000cwd.googlegroups.com!not-for-mail From: "Adam Beneschan" Newsgroups: comp.lang.ada Subject: Re: how to import a package Date: 5 Dec 2006 19:06:04 -0800 Organization: http://groups.google.com Message-ID: <1165374364.874225.237370@n67g2000cwd.googlegroups.com> References: <1165371252.358817.57840@80g2000cwy.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: posting.google.com 1165374391 21227 127.0.0.1 (6 Dec 2006 03:06:31 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 6 Dec 2006 03:06:31 +0000 (UTC) User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: n67g2000cwd.googlegroups.com; posting-host=66.126.103.122; posting-account=cw1zeQwAAABOY2vF_g6V_9cdsyY_wV9w Xref: g2news2.google.com comp.lang.ada:7817 Date: 2006-12-05T19:06:04-08:00 List-Id: 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