comp.lang.ada
 help / color / mirror / Atom feed
* array slices
@ 2003-05-13  1:24 gshibona @ b e l l s o u t h . n e t
  2003-05-13  1:28 ` Jeffrey Carter
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: gshibona @ b e l l s o u t h . n e t @ 2003-05-13  1:24 UTC (permalink / raw)


I wonder if someone could point to the error in this code.  I'm looking
to fill array a with a "row" slice
of array c.   There doesn't appear to be much info on this particular
facet of Ada, yet what I have seen
suggests that the syntax below is correct.

procedure ada_2daryslice is

a : array(1..4) of integer;
c : array( 1..2, 1..4 ) of integer;

begin
    c :=  (
         1 => (0, 1, 2, 4 ),
         2 => (8, 16, 32, 64)
         );
    -- this seems to yield the expected results
    a(1..4) := ( 1,2,3,4);

    -- however, this does not...
    a(1..4) := c(1)(1..4);

end ada_2daryslice;

The compiler complains of too few subscripts in the array reference.
To wit...

gnatmake -g -gnatv ada2daryslice.adb
gnatgcc -c -g -gnatv ada2daryslice.adb

GNAT 3.13p  (20000509) Copyright 1992-2000 Free Software Foundation,
Inc.

Compiling: ada2daryslice.adb (source file time stamp: 2003-05-13
01:20:09)

    17.     a(1..4) := c(1)(1..4);
                                   |
        >>> too few subscripts in array reference

 17 lines: 1 error
gnatmake: "ada2daryslice.adb" compilation error

It's quite possible that I've been looking at this for much too long to
be objective.   Thanks in advance
for any help.

Ger





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-05-13 11:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-13  1:24 array slices gshibona @ b e l l s o u t h . n e t
2003-05-13  1:28 ` Jeffrey Carter
2003-05-13  1:49 ` tmoran
2003-05-13 11:53 ` James S. Rogers

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