17132, “vasslitvinov”, “Range slicing syntax”, “2021-02-09T08:17:53Z”
This issue asks whether we can improve the way range slicing is written.
In our range module review on 2/04 a few of us noted that the current way to slice a range unintuitive:
Here are our considerations:
The obvious alternative is to introduce a slicing method, ex.
especially that we already have
Slicing is particularly useful on domains and arrays. Some prefer to write it with square brackets, as in
expr1[expr2], although Chapel treats it the same as parens.
Having to write
A[x..y]can be seen as a step backwards.
We could potentially support both the paren form and a method.
Although this goes against the principle that there should not be two ways of doing the same thing.
Whatever we do, it should be consistent between ranges, domains, and arrays.
If expr1 is range and expr2 is an integer,
expr1(expr2)should be a valid “element access” (by analogy to indexing into an array), perhaps meaning