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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c180f7ec8c114391 X-Google-Attributes: gid103376,public From: stt@henning.camb.inmet.com (Tucker Taft) Subject: Re: Can a generic conatain another generic Date: 1996/04/29 Message-ID: #1/1 X-Deja-AN: 152042554 sender: news@inmet.camb.inmet.com (USENET news) x-nntp-posting-host: henning.camb.inmet.com references: <3180C808.63F1A041@jinx.sckans.edu> organization: Intermetrics, Inc. newsgroups: comp.lang.ada Date: 1996-04-29T00:00:00+00:00 List-Id: 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