comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: GENERIC SPEC TYPE ERROR
Date: Wed, 16 Nov 2005 12:33:39 +0100
Date: 2005-11-16T12:33:39+01:00	[thread overview]
Message-ID: <1ceeqn37k0ijy$.1x9q3lh6sbjft$.dlg@40tude.net> (raw)
In-Reply-To: 1132137814.272620.71410@f14g2000cwb.googlegroups.com

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



  parent reply	other threads:[~2005-11-16 11:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-16 10:43 GENERIC SPEC TYPE ERROR rashmi
2005-11-16 11:23 ` Georg Bauhaus
2005-11-16 11:33 ` Dmitry A. Kazakov [this message]
2005-11-18 11:58   ` rashmi
replies disabled

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