comp.lang.ada
 help / color / mirror / Atom feed
From: Ludovic Brenta <ludovic@ludovic-brenta.org>
Subject: Re: Array of Strings
Date: Tue, 23 Sep 2008 07:47:23 -0700 (PDT)
Date: 2008-09-23T07:47:23-07:00	[thread overview]
Message-ID: <28f46a26-60d3-436d-96bb-11404fa66b4d@p25g2000hsf.googlegroups.com> (raw)
In-Reply-To: 03c0a846-728a-4944-9529-9b941f7361e9@y21g2000hsf.googlegroups.com

mockturtle wrote:
> On Sep 23, 4:07 pm, jedivaughn <jedivaugh...@gmail.com> 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)

That's correct.

To the OP: out of curiosity, why don't you use Ada.Containers.Vectors?
Even if you have good reason not to use this package, you will benefit
from reading its spec as a source of inspiration (aka "best
practices").

Also see http://en.wikibooks.org/wiki/Ada_Programming/Generics

--
Ludovic Brenta.



  parent reply	other threads:[~2008-09-23 14:47 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 [this message]
2008-09-23 18:51       ` Jeffrey R. Carter
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