comp.lang.ada
 help / color / mirror / Atom feed
From: kst@alsys.com (Keith Thompson @pulsar)
Subject: Re: Change in behavior of & operator between 83 and 9x?
Date: Thu, 13 Oct 1994 01:43:46 GMT
Date: 1994-10-13T01:43:46+00:00	[thread overview]
Message-ID: <CxL8sz.G6H@alsys.com> (raw)
In-Reply-To: 19941006.090935.490@vnet.ibm.com

In <19941006.090935.490@vnet.ibm.com> karthurs@vnet.ibm.com (Keith Arthurs) writes:
> In article <GRAHAM.94Oct5120449@canopus.clsi.COM>,
>  on 05 Oct 1994 16:04:49 GMT,
>  Paul Graham <graham@clsi.COM> writes:
> >
> >If an array type A has component type B which is itself an array type, is it
> >possible to concatenate two arrays of type B to produce an array of type A?
> >For instance:
> >
> >    package foo is
> >     type my_string is array(1 .. 3) of character;
> >     type my_string_vector is array(positive range <>) of my_string;
> >     c1 : my_string_vector := "abc" & "def";
> 
> In Ada 83 'my_string_vector' would need to be constrained (1 .. 2)
> (lrm 3.6.1:6)
> 
> >    end;
> >
> >In this example, I want the value of the concanenation to be equivalent to
> >
> >     ("abc", "def")  -- my_string_vector(1 to 2)
> 
> This is a correct interpretation of 'my_string_vector', it is a two
> dimensional array

A quibble: it's not a two dimensional array, it's a one dimensional array
whose component type is also a one dimensional array.  (Unlike Pascal,
for example, Ada does distinguish between these two cases.)

For example:

    type Array_1d    is array(1 .. 3) of Integer;
    type Array_1d_1d is array(1 .. 3) of Array_1d;
    --
    -- Array_1d_1d is a 1-d array of 1-d arrays
    --

    type Array_2d    is array(1 .. 3, 1 .. 3) of Integer;
    --
    -- Array_2d is a 2-d array
    --

Just to add to the confusion, both types use the same syntax for aggregates:

    Obj_1d_1d: Array_1d_1d
        := (1 => (1, 2, 3),
            2 => (4, 5, 6),
            3 => (7, 8, 9));

    Obj_2d: Array_2d
        := (1 => (1, 2, 3),
            2 => (4, 5, 6),
            3 => (7, 8, 9));

-- 
Keith Thompson (The_Other_Keith)  kst@alsys.com
TeleSoft^H^H^H^H^H^H^H^H Alsys, Inc.
10251 Vista Sorrento Parkway, Suite 300, San Diego, CA, USA, 92121-2718
/user/kst/.signature: I/O error (core dumped)



       reply	other threads:[~1994-10-13  1:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <19941006.090935.490@vnet.ibm.com>
1994-10-13  1:43 ` Keith Thompson @pulsar [this message]
1994-10-05 16:04 Change in behavior of & operator between 83 and 9x? Paul Graham
replies disabled

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