chapel-lang / chapel

a Productive Parallel Programming Language
https://chapel-lang.org
Other
1.78k stars 418 forks source link

Extend formal query syntax to support querying array ranges #14606

Open bradcray opened 4 years ago

bradcray commented 4 years ago

[Spun off of from issue #14590]

As a Chapel programmer, I'd like the ability to use Chapel's query syntax to pick the individual ranges out of a multidimensional array. For example, imagine:

proc foo(X: [?D1] real, Y: [?r1, ?r2] ?yt, Z: [?r3, ?r4, ?r5] ?zt) { ... }

where

Similarly, we might consider extending the empty tuple syntax to break a 1D domain down into its range using:

proc foo(X: [?r1, ]) { ... }

though this could be confusing if we also support proposed syntax for specifying that an array must be 2D (e.g., for interoperability purposes) as follows:

proc foo(X: [ , ]) { ... }  // X must be 2D but we don't want to say what its indices are

Another way to express the case of breaking a 1D array's domain down into ranges might be to permit the curly braces to be specified, to imply that we're unpeeling the domain:

proc foo(X: [{?r1}], Y: [{?r2, ?r3], Z: [{?r4, ?r5, ?r6}] ) { ... }

test/arrays/formals/queryMultiDimByRange.chpl #14608

damianmoz commented 4 years ago

Definitely a useful feature.