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=0.2 required=5.0 tests=BAYES_00,REPLYTO_WITHOUT_TO_CC, SUBJ_ALL_CAPS autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,4ae5e9a205d57072 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: GENERIC SPEC TYPE ERROR Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1132137814.272620.71410@f14g2000cwb.googlegroups.com> Date: Wed, 16 Nov 2005 12:33:39 +0100 Message-ID: <1ceeqn37k0ijy$.1x9q3lh6sbjft$.dlg@40tude.net> NNTP-Posting-Date: 16 Nov 2005 12:33:39 MET NNTP-Posting-Host: f364e690.newsread4.arcor-online.net X-Trace: DXC=g2dPN1jS@KoIeeCiY5g2Vc:ejgIfPPlddjW\KbG]kaMh1BZS;MmC65fj6FTHJKhc On 16 Nov 2005 02:43:34 -0800, rashmi wrote: > I have created a generic specification for doing a vector operation > called PROC_Kronecker as shown below. > ------------------------------------------------------------------------------------------------------------------------------------ > File: PROC_KRONECKER.ads > ------------------------------------------------------------------------------------------------------------------------------------ > > > generic > type PV_Vtyp is Private ; > type VC_Rnge is range <>; > type VC_Type is array(VC_Rnge) of PV_Vtyp; > with function "*"(PV_Left,PV_Rigt : in PV_Vtyp) return PV_Vtyp; > procedure PROC_Kronecker(VC_Left , VC_Rigt : in VC_Type;VC_Resl:out > VC_Type); > > ------------------------------------------------------------------------------------------------------------------------------------ > > The associated body PROC_KRONECKER.adb works correctly for the above > spec. But when I tried to change the VC_Rnge and VC_Type to the > following: > > type VC_Rnge is Positive; > type VC_Type is array(1..VC_Rnge) of PV_Vtyp; > > then GNAT did not compile saying "Expecting generic type definition > here" where I have declared "Positive". Can someone clarify precisely > why the above cannot be valid ? type VC_Rnge is Positive <-- here a generic type specification is expected. You have "Positive" instead, which is not generic, but a concrete type. Generic types are sets of types. You can consider them as types of types, which values are normal types. The following line is also wrong. VC_Rnge is a type, but 1..VC_Rnge assumes a value. Probably generic type Element_Type is Private ; type Index_Type is range <>; type Array_Type is array (Index_Type range <>) of Element_Type; with function "*" (Left, Right : Element_Type) return Element_Type is <>; function Kronecker (Left, Right : Array_Type) return Element_Type; is what you need. However it is not clear what are you trying to achieve. What should be variable in your generic package 1) the types or 2) constraints on types or some mixture of both? -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de