On Sun, 18 Mar 2018, Brad Chamberlain wrote:

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

I will look at it over the next week. I can see where you are coming from
but, Hmmm. Need to think.

If y and e are 1D-arrays, this works

        y[1..n] = e[1..n] * 2.0;

but if x is an array of arrays, then as Chapel is now, the LHS of this

        x[1..n][10] = e[1..n] * 2.0;

is a scalar (not a vector) and the RHS is still a vector. I need to think
about it because

        x[10][1..n] = e[1..n] * 2.0;

is OK.

It would seem that an array of arrays is not slicable, only a 1-D array is. This is getting into C territory where an array was/is a 2nd class object.

Even now, a Chapel n-dimensional array is a 2nd class object because you cannot assign literals to it in a declaration. I use an array of an array for a matrix to let me initialize it. But I have just seen that this now has other implications.

Initialization seems a difficult area. We still do not seem to have a solution for real(w)'s are because there are initialization issues still.

For a user like myself, what that also means is that Chapel says that

        x[2..3][6]
and
        x[2..3, 6]

are very different beasts. The first is the 6th element of a slice. The second is a slice. I would argue that they should be pretty similar. Well, I have used them that way in C/C++ for 30 years. Maybe I am odd!

I always thought that Pascal/Modula's array of arrays and multidimensional arrays were much of a muchness.

Let's look at the construct (a concise parallel forall)

        [<ind> in <slice>] expression which is a function of i

To match the way Fortran has done for a long time, you need to be able to replace the <ind> within the expression by the <slice> and have no change in the behaviour. For better or worse, you are not going to for a change to 40 years of Fortran user code/habits, especially if you are aiming for Fortran HPC converts. Otherwise, slicing as done now is of very limited value, well at least for HPC. Even if from a computer science perspective, the way Fortran does it is grubby. Mind you, Intel adopted the Fortran way for their C/C++ I believe.

Just my 2c.

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

Reply via email to