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,7b4ed0d42717e891 X-Google-Attributes: gid103376,public From: stt@houdini.camb.inmet.com (Tucker Taft) Subject: Re: [Technical] Generic child parameterised with instance of parent Date: 1998/11/29 Message-ID: #1/1 X-Deja-AN: 416785073 Sender: news@inmet.camb.inmet.com (USENET news) X-Nntp-Posting-Host: houdini.camb.inmet.com References: <365D6AFE.D3BEE7D1@elca-matrix.ch> Organization: Intermetrics, Inc. Newsgroups: comp.lang.ada Date: 1998-11-29T00:00:00+00:00 List-Id: Mats Weber (Mats.Weber@elca-matrix.ch) wrote: : Michel Gauthier wrote: : > Here is the need as I can identify it (possibly not in a right way). : > Then can be compiled. But the compiler rejects : > package InstChild is new P1Some . Child ( P1Other ) ; : GNAT 3.11b accepts this, and does not need the G1bis declaration, so it : does not seem to take G1 as denoting the current instance within the : generic formal part of G1.Child. I don't know if that is right or not. This sounds like a bug. Everywhere inside the declarative region of G1, G1 denotes the "current instance." : Here is the exact code that I compiled: : with G1.Child; : procedure Gauthier_Generic_Child is : type Some_Type is new Integer; : type Other_Type is new Float; : package P1_Some is new G1 ( some_type ) ; : package P1_Other is new G1 ( other_type ) ; : package InstChild is new P1_Some . Child ( P1_Other ) ; : begin : null; : end; : --- : generic : with package GP is new G1 ( <> ) ; This is definitely wrong; G1 is not a generic inside G1. : package G1 . Child is : end; : --- : generic : type ITEM is private; : package G1 is : end G1; I might add that, inside a child of G1, you don't normally need to pass in an instance of G1, because an instance of G1 must be specified as a prefix when instantiating the child, and that instance can be referenced inside the child by simply using the name "G1." If you need *two* instances of the parent generic inside the child, then you probably do need to do the generic renaming trick. -- -Tucker Taft stt@inmet.com http://www.inmet.com/~stt/ Intermetrics, Inc. Burlington, MA USA An AverStar Company