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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,504fffc448fde1d6 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-02-26 13:33:23 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!sunqbc.risq.qc.ca!newsfeed.mathworks.com!intgwlon.nntp.telstra.net!news.telstra.net!news-server.bigpond.net.au!not-for-mail From: Dale Stanbrough Newsgroups: comp.lang.ada Subject: Re: How do you instantiate a private package? References: <20020226155831.07840.00000639@mb-mn.aol.com> User-Agent: MT-NewsWatcher/3.2 (PPC Mac OS X) Message-ID: Date: Tue, 26 Feb 2002 21:33:20 GMT NNTP-Posting-Host: 144.132.91.90 X-Complaints-To: news@bigpond.net.au X-Trace: news-server.bigpond.net.au 1014759200 144.132.91.90 (Wed, 27 Feb 2002 08:33:20 EST) NNTP-Posting-Date: Wed, 27 Feb 2002 08:33:20 EST Organization: BigPond Internet Services (http://www.bigpond.net.au) Xref: archiver1.google.com comp.lang.ada:20476 Date: 2002-02-26T21:33:20+00:00 List-Id: Joshua Shriver wrote: > I've created a package called direct_file_stuff in my ads and adb and > instantiate a direct_io package called dfs_pkg. > > Now that I have this package created, how do I use it in an application? > > Here is my .ads > > with direct_io; > > generic > type item is private; > > package dfs is > package dfs_pkg is new direct_io(item); > use dfs_pkg; > > procedure switch_file_lines(source_file: in string; line1: integer; line2: > integer); > > procedure swap_head_tail(source_file: in string; lines: integer); > > procedure get_middle(source_file: in string; found: out item); > > end dfs; > > I've implemented this functions in dfs.adb but now I can't figure out how to > use this procedure in a main application. How is this done? with dfs; procedure main is package my_dfs is new dfs (integer); -- or whatever type file : mydfs.dfs_pkg.file_type; -- note that the use clause inside the dfs generic only -- extends to the end of the generic spec (or body, i can't -- remember). Anyway it doesn't extend outside. -- You could have another use clause here... use mydfs.dfs_pkg; -- replicates the use clause in the generic spec, but in -- the current scope begin open (file, mydfs.dfs_pkg.in_file, "wow"); end; Mind you I think a better organisation is to have most generic instantiations in a separate compilation unit (at the library level). with dfs; with My_Package_With_Type_Defs; use My_Package_With_Type_Defs; package mydfs is new dfs (My_Special_Type); Dale