Open
Description
While working on some array-of-array code recently, I found myself wondering which sorts of promotions we think ought to work in Chapel for arrays-of-arrays:
// Given:
var A: [1..3] [1..3] [1..3] real;
// This works because A and D have the same type/shape
var D: [1..3] [1..3] [1..3] real;
A = D;
// this works because C.type == A.eltType, so it's a normal promotion
var C: [1..3] [1..3] real;
A = C;
// this seems like perhaps it should work, but it doesn't. We get "cannot iterate over values of type real(64)
A = 1.2; // error: cannot iterate over values of type real(64)
// this also seems like it could arguably work as a promotion over the second level of A, but it similarly doesn't
var B: [1..3] real;
A = B; // error: cannot iterate over values of type real(64)
Similarly, should one be able to call sin(A)
or A + D
and get an array-of-array-of-array-of-real result?
In essence, this issue asks "Should promotion be recursively considered in array-of-array situations, or restricted only to the outermost array, as it currently seems to be?"
Activity
damianmoz commentedon Mar 6, 2025
I am assuming that the third case of A = C is just
I am still trying to understand the precise difference between a multi-dimensional array and an array of arrays [of arrays]. Too much historical baggage in my head and a lack of understanding of what must work for the case of distributed memory.
bradcray commentedon Mar 6, 2025
That's right. And if the A = B; case was supported, you could imagine it being:
Let us know if we can help clarify anything here (though ideally in a forum other than this issue).