chapel-lang / chapel

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

Support inferred-size arrays via partially bounded ranges #10596

Open bradcray opened 6 years ago

bradcray commented 6 years ago

For about as long as Chapel has existed (e.g., see this future from 2008), there's been an intention to support inferred-size arrays using domains involving partially bounded ranges like the following:

var A: [0..] real = [1.0, 2.0, 3.0];     // I'm too lazy to declare this as `[0..2] real`
var B: [0..] real = readValsFromFile();  // I'm not sure how many values I'll get but want to index from 0
var C: [3..] real = readValsFromFile();  // I want to be able to use arbitrary lower bounds

In addition, one might want to use this form to declare a function's return type:

proc readArr(): [0..] real {
  var A: [0..] real = readValsFromFile();
  return A;
}

or:

proc readArr(): [0..] real {
  var size = readSizeFromFile();
  var A: [0..#size] real = readValsFromFile();
  return A;
}

Today this results in an error because we build the domain before building the array and require domains to be defined using bounded ranges (something we probably want to retire for other reasons—see issue #10595).

bradcray commented 6 years ago

@lydia-duncan : This is the feature request I mentioned today.

bradcray commented 4 years ago

This feature would be a big boon for index-neutral programming, even if it was only supported for 1D arrays.

bradcray commented 7 months ago

I've added the 'user issue' label here because @damianmoz expressed interest in this feature in https://github.com/chapel-lang/chapel/issues/24440.