* Can a generic conatain another generic
@ 1996-04-26 0:00 David Morton
1996-04-29 0:00 ` Tucker Taft
0 siblings, 1 reply; 2+ messages in thread
From: David Morton @ 1996-04-26 0:00 UTC (permalink / raw)
A little question... can a generic package
contain another generic package?
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 <>;
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.
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...
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?
--
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) :)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Can a generic conatain another generic
1996-04-26 0:00 Can a generic conatain another generic David Morton
@ 1996-04-29 0:00 ` Tucker Taft
0 siblings, 0 replies; 2+ messages in thread
From: Tucker Taft @ 1996-04-29 0:00 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1996-04-29 0:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-04-26 0:00 Can a generic conatain another generic David Morton
1996-04-29 0:00 ` Tucker Taft
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox