Re: Array of Strings

On Sep 13, 7:18 am, jedivaughn <jedivaugh...@xxxxxxxxx> wrote:
Hi everyone,

I'm having trouble making a array of type string. can some one show me
how to do this. I've tried type letters is array (Integer range <>) of
String; but I get error "unconstrained element type in array
declaration". what am I doing wrong?

One of the things that needs to be impressed upon newer Ada
programmers is that Ada's String type is *not* a varying-length
string. Some languages have varying-length strings built into them,
like BASIC and Perl; you can just assign a 2-character string into a
string variable, and later change it to an 80-character string, and
later to an empty (zero-length) string, and so on, without worrying
too much. (I believe there are many other languages that also have
this sort of string type.) Ada's String type is not like this. A
String variable has a particular length and that length cannot be
changed. (Maybe it was a mistake to name it "String" because of the
potential for confusion.)

Ludovic already mentioned Bounded_String and Unbounded_String which
were added in Ada 95 to fill that hole.

-- Adam