chapel-lang / chapel

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

Unpack arrays into arguments #15518

Open ben-albrecht opened 4 years ago

ben-albrecht commented 4 years ago

Support unpacking an array into function arguments similar to a tuple. I propose the same syntax of unpacking a tuple here, because Python uses the same syntax for unpacking tuples and lists as arguments (f(*tuple) and f(*list)).

var A = [1, 2, 3];

proc f(a, b, c) {
  return a + b +c;
}

var sum = f(...A); // or some other syntax

This feature requires array size to be known at compile-time, i.e. arrays with param size, as a prerequisite.

ben-albrecht commented 4 years ago

This feature requires array size to be known at compile-time, i.e. arrays with param size, as a prerequisite.

I am not aware of an issue for this. TODO: Find or open an issue for this feature request as well.