comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.acm.org>
Subject: Re: Array of Strings
Date: Tue, 23 Sep 2008 18:51:42 GMT
Date: 2008-09-23T18:51:42+00:00	[thread overview]
Message-ID: <2VaCk.356477$yE1.321489@attbi_s21> (raw)
In-Reply-To: <0e021c61-535a-4935-95ad-2a241fa7302f@e53g2000hsa.googlegroups.com>

jedivaughn 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 (<>);

This specifies that the actual for Element_Type must a discrete type, as the 
error msg indicates.

>     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);

Presumably you want Element_Type to be private, which allows any non-limited 
type you can declare an object of without an initialization. I presume you're 
doing this to learn about generics, since what you have here doesn't do anything 
worthwhile.

There is also a way to define your component type as an array type:

generic -- List
    type Element_Component is private;
    type Element_Index is (<>);
    type Element is array (Element_Index) of Element_Component;
    type Letters_Index is (<>);
package List is
    type Letters is private;
private -- List
    type Letters is array (Letters_Index) of Element;
end List;

This is more restrictive than private.

-- 
Jeff Carter
"Sir Lancelot saves Sir Gallahad from almost certain temptation."
Monty Python & the Holy Grail
69



  parent reply	other threads:[~2008-09-23 18:51 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-13 14:18 Array of Strings jedivaughn
2008-09-13 14:32 ` Ludovic Brenta
2008-09-14  0:11 ` anon
2008-09-14  9:45 ` Per Sandberg
2008-09-15 14:54 ` Adam Beneschan
2008-09-16 23:56   ` jedivaughn
2008-09-23 14:07     ` jedivaughn
2008-09-23 14:30       ` mockturtle
2008-09-23 14:41         ` Adam Beneschan
2008-09-23 14:47         ` Ludovic Brenta
2008-09-23 18:51       ` Jeffrey R. Carter [this message]
2008-09-24 12:00         ` jedivaughn
2008-09-24 14:36           ` Adam Beneschan
2008-09-24 15:13           ` John McCormick
2008-09-24 17:18           ` Jeffrey R. Carter
2008-09-28 12:24             ` jedivaughn
2008-09-28 13:01               ` mockturtle
2008-09-28 17:08                 ` jedivaughn
2008-09-29 11:14                   ` mockturtle
2008-09-28 19:00               ` Jeffrey R. Carter
2008-09-29 15:51                 ` Adam Beneschan
replies disabled

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