comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Global scope for instantiated generic package?
Date: Mon, 30 Aug 2010 15:47:05 +0200
Date: 2010-08-30T15:47:05+02:00	[thread overview]
Message-ID: <nmgjc2ylxwuw$.syobfl3ihlct.dlg@40tude.net> (raw)
In-Reply-To: 5vWdnTd5Lf6uM-bRnZ2dnUVZ_oidnZ2d@giganews.com

On Mon, 30 Aug 2010 08:12:19 -0500, Trogdor wrote:

> I wish to manipulate very large integers with values in the 
> trillions.  This 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?

I usually do it this way:

package Big_Integers is
   type Big_Integer is range 1..10_000_000_000_000;
end Big_Integers;

Further instantiations based on it go into children packages:

with Ada.Text_IO;  use Ada.Text_IO;
package Big_Integers.IO is new Integer_IO (Big_Integer);

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  parent reply	other threads:[~2010-08-30 13:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-30 13:12 Global scope for instantiated generic package? Trogdor
2010-08-30 13:25 ` Jacob Sparre Andersen
2010-08-30 13:28 ` Georg Bauhaus
2010-08-30 13:30 ` Ludovic Brenta
2010-08-30 13:47 ` Dmitry A. Kazakov [this message]
2010-08-30 18:49 ` Jeffrey 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