comp.lang.ada
 help / color / mirror / Atom feed
From: stt@henning.camb.inmet.com (Tucker Taft)
Subject: Re: Can a generic conatain another generic
Date: 1996/04/29
Date: 1996-04-29T00:00:00+00:00	[thread overview]
Message-ID: <DqMMns.2rw.0.-s@inmet.camb.inmet.com> (raw)
In-Reply-To: 3180C808.63F1A041@jinx.sckans.edu


David Morton (dmorton@jinx.sckans.edu) wrote:
: A little question...  can a generic package
: contain another generic package?

Yes.

: In particular, I have an integer type declared
: in a file_IO package, which a management package uses.
: The management package uses another screen_IO package
: for, you guessed it, screen io.  The trouble is, I need
: to prompt for that integer type, making the screen_IO package
: have to "with" the file_IO package. I really don't want
: these two packages to have any inter-dependencies,
: so it seems to me that I need the screen_IO to have a generic function,
: instantiated with the management prog.  But the screen_IO
: package will *also* have to instantiate Text_IO.Integer_IO.
: any ideas how to do this?

: I tried something like:

: generic
:  type Integer_Type is <>;
                        ^^^ "range <>"
:  function Get_Index_Prompt(prompt : in string) return Integer_Type is
:  Index_IO is new Text_IO.Integer_IO(Integer_Type);
: ...


: but it needs a type where the <> is.

No, it needs a "formal type definition."  To indicate you
are expecting some integer type, write "range <>".

: private won't work, cause the instantiation of Text_IO.Integer_IO
: needs an integer type.
: private integer won't work either...  somehow I need to tell the
: generic declaration that Integer_Type *will* be an integer.
: but I can't just say "Integer" because it is only a particular integer type...

"range <>" does exactly what you want.


: The only other way to fix this is with a type cast in the management
: program, which, I believe, is usually frowned upon.

: any suggestions?

See above.

: David Morton
:  mailto:dmorton@jinx.sckans.edu    // If you use Netscape 2.0,
:  205 College, Winfield, KS 67156   // you can click on the mailto: part to reply!
:                                    (HINT, HINT)  :)

-Tucker Taft   stt@inmet.com   http://www.inmet.com/~stt/
Intermetrics, Inc.  Cambridge, MA  USA




      reply	other threads:[~1996-04-29  0:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-04-26  0:00 Can a generic conatain another generic David Morton
1996-04-29  0:00 ` Tucker Taft [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox