chapel-lang / chapel

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

Support unbounded domains #10595

Open bradcray opened 6 years ago

bradcray commented 6 years ago

Traditionally, Chapel hasn't supported domains over unbounded ranges for the naive reason that arrays declared over them would be (conceptually) infinite, which didn't make sense:

const D = {1.., 1..};
var A: [D] real;   // requires a conceptually infinite amount of storage

However, such domains can be useful for other contexts such as slicing, serial iteration, etc. For instance:

const PosRows = {1.., ..};

var A: [-3..3, -3..3] real;

writeln(A[PosRows]);  // print out only the slice of A whose row indices are positive

For this reason, it seems like the prohibition against domains with unbounded ranges should be moved from domain creation time to array creation / allocation time.

bradcray commented 6 years ago

Note that there's a potentially interesting interplay between this feature and issue #10596. Specifically, my intuition is that we wouldn't want to have:

var D = {0..};
var A: [D] real = readValsFromFile();

be legal and behave like the following:

var A: [0..] real = readValsFromFile();

But certain implementations of the second might cause the first to work as well (?). This also touches up against issue #5053.