Re: Array of Strings
- From: Adam Beneschan <adam@xxxxxxxxxx>
- Date: Tue, 23 Sep 2008 07:41:06 -0700 (PDT)
On Sep 23, 7:30 am, mockturtle <framefri...@xxxxxxxxx> wrote:
On Sep 23, 4:07 pm, jedivaughn <jedivaugh...@xxxxxxxxx> wrote:
If I wanted to make a package that made the array generic how would I
go about doing this. this is what I have which isn't working.
generic
type Element_Type is (<>);
type range1 is (<>);
package list is
type letters is private;
private
type letters is array (range1) of Element_Type;
end list;
and then in the main program I want
subtype range2 is integer range 1..25;
subtype str_length is string (1..25);
package List1 is new List(Element_Type => str_length, range1 =>
range2 );
when I try to compile the main program I get "expect discrete type in
instantiation of "Element_Type""
what am I doing wrong?
According to RM 12.5.2 "type Element_Type is (<>);" means that
Element_Type
is a discrete type. I guess that you want something like
"type Element_Type is private;" (I did not check)
Yes, that's right. When you declare a generic formal type (a "type"
declaration between the keyword "generic" and the beginning of the
package or procedure declaration), there are several ways to declare
the type, and the different ways control what sorts of types you can
use to instantiate the generic. Here's an incomplete rundown:
type T is private; -- T can be any nonlimited type except an
-- unconstrained type
type T(<>) is private; -- T can be any nonlimited type
type T is (<>); -- T must be discrete, i.e. integer or
-- enumeration
type T is range <>; -- T must be a signed (non-modular) integer
type
type T is mod <>; -- T must be a modular type
type T is digits <>; -- T must be a floating-point type
type T is delta <>; -- T must be a fixed-point type, not decimal
fixed
type T is delta <> digits <>; -- T must be a decimal fixed-point type
You can also declare formal array types, access types, and derived
types. Also, the "private" generic formal declarations can have
"tagged" and/or "limited" keywords applied. See the manual (12.5) for
more information.
-- Adam
.
- References:
- Array of Strings
- From: jedivaughn
- Re: Array of Strings
- From: Adam Beneschan
- Re: Array of Strings
- From: jedivaughn
- Re: Array of Strings
- From: jedivaughn
- Re: Array of Strings
- From: mockturtle
- Array of Strings
- Prev by Date: Re: Array of Strings
- Next by Date: Re: Array of Strings
- Previous by thread: Re: Array of Strings
- Next by thread: Re: Array of Strings
- Index(es):
Relevant Pages
|
Loading