From: Jacob Sparre Andersen <sparre@nbi.dk>
Subject: Re: Global scope for instantiated generic package?
Date: Mon, 30 Aug 2010 15:25:00 +0200
Date: 2010-08-30T15:25:00+02:00 [thread overview]
Message-ID: <87k4n8utar.fsf@hugsarin.sparre-andersen.dk> (raw)
In-Reply-To: 5vWdnTd5Lf6uM-bRnZ2dnUVZ_oidnZ2d@giganews.com
Trogdor wrote:
> type BigInt is range 1..10_000_000_000_000;
This has to be done in a declarative region (i.e. inside a package or
subprogram). This could be in a completely independent package:
-- trogdor.ads (for GNAT)
package Trogdor is
type Integer is range 1..10_000_000_000_000;
end Trogdor;
> I then wish to get and put these values, so I instantiate
> Integer_IO.
>
> package BigInt_IO is new integer_IO(BigInt);
This can be a complation unit of its own:
-- trogdor_io.ads (for GNAT)
with Trogdor;
package Trogdor_IO is new Ada.Text_IO.Integer_IO (Trogdor.Integer);
Or you can put it inside the same package as the number type:
-- trogdor.ads (for GNAT)
package Trogdor is
type Integer is range 1..10_000_000_000_000;
package IO is new Ada.Text_IO.Integer_IO (Integer);
end Trogdor;
> 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?
If the subprograms are specific to the program, you may want to declare
them in the declarative part of the program rather than in a separate
package.
Kind regards,
Jacob Sparre Andersen
--
Jacob Sparre Andersen Research & Innovation
Vesterbrogade 148K, 1. th.
1620 K�benhavn V
Danmark
Phone: +45 21 49 08 04
E-mail: jacob@jacob-sparre.dk
Web-site: http://www.jacob-sparre.dk/
next prev parent reply other threads:[~2010-08-30 13:25 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 [this message]
2010-08-30 13:28 ` Georg Bauhaus
2010-08-30 13:30 ` Ludovic Brenta
2010-08-30 13:47 ` Dmitry A. Kazakov
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