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,45fb44c5bf432111 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!a36g2000yqc.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Global scope for instantiated generic package? Date: Mon, 30 Aug 2010 06:30:17 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <5vWdnTd5Lf6uM-bRnZ2dnUVZ_oidnZ2d@giganews.com> NNTP-Posting-Host: 153.98.68.197 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1283175060 9485 127.0.0.1 (30 Aug 2010 13:31:00 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 30 Aug 2010 13:31:00 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: a36g2000yqc.googlegroups.com; posting-host=153.98.68.197; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6,gzip(gfe) Xref: g2news1.google.com comp.lang.ada:13853 Date: 2010-08-30T06:30:17-07:00 List-Id: Trogdor wrote on comp.lang.ada: > I wish to manipulate very large integers with values in the > trillions. =A0This would require a 64 bit integer type, so to maintain > portability I specify a new type using range and let the compiler do > the right thing. > > type BigInt is range 1..10_000_000_000_000; > > I then wish to get and put these values, so I instantiate > Integer_IO. > > package BigInt_IO is new integer_IO(BigInt); > > My program consists of three parts: the main body, a package spec > and a package body (the package containing all the subprograms and > functions). > > 1) Is this the way to do it, or is there a preffered way? > > 2) Where, speciffically, do I place the above two lines (and the > associated "with" line) so that I can BigInt_io.get from the main > body and the package subprograms as well? > > So far, every place I have tried has offended the compiler. =A0And my > text books have been of little help (I have more on order). > > Thanks for the help! Without at least a sekeleton of your sources I'm not sure I understand your question, so for clarity I'll assume you currently have: with Ada.Text_IO; package P is type BigInt is range 1..10_000_000_000_000; package BigInt_IO is new Ada.Text_IO.Integer_IO (BigInt); procedure Proc (X : out BigInt); end P; package body P is procedure Proc (X : out BigInt) is begin BigInt_IO.Get (X); -- OK end Proc; end P; with P; procedure Main is X : BigInt; begin P.Proc (X); -- OK BigInt_IO.Get (X); -- error, BigInt_IO not directly visible P.BigInt_IO.Get (X); -- OK end Main; You can resolve the error in two ways: 1) add a "use P;" clause in procedure Main 2) Declare BigInt_IO at library level, like so: -- bigint_io.ads with Ada.Text_IO; with P; package BigInt_IO is new Ada.Text_IO.Integer_IO (P.BigInt); and then add "with BigInt_IO" clauses in both the body of P and the body of Main. HTH -- Ludovic Brenta.