Hi Damian --

This is a question that comes up from time to time, and to which I don't feel confident we've done the right thing. Essentially what happens in Chapel today is that the array slice a[2..3] is itself an expression with array type over the indices 2..3 (like a small virtual array) and so the next index [1] is being applied to the array expression returned by the slice rather than the array elements of the original array / the slice. This issue captures more about this topic, including my wrestling through what it would take to do something different:

        https://github.com/chapel-lang/chapel/issues/5568

Comments very welcome,
-Brad


On Sun, 18 Mar 2018, Damian McGuckin wrote:


Let's try something simpler:

This complete program works.

        var a : [1..3][1..3] real;

        a[1..3][1] = -3.0;
        // a[2..3][1] = -3.0;
        a[1..3][2] = 3.0;
        a[1..3][3] = 3.0;
        writeln(a);

Uncomment that comment and it does not.

        var a : [1..3][1..3] real;

        a[1..3][1] = -3.0;
        a[2..3][1] = -3.0;
        a[1..3][2] = 3.0;
        a[1..3][3] = 3.0;
        writeln(a);

failing with

        halt reached - array index out of bounds:

What am I doing that is wrong?  It's just slicing and dicing.

Regards - Damian

Pacific Engineering Systems International, 277-279 Broadway, Glebe NSW 2037
Ph:+61-2-8571-0847 .. Fx:+61-2-9692-9623 | unsolicited email not wanted here
Views & opinions here are mine and not those of any past or present employer

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers

Reply via email to