Chapel: Should lists support slicing by unbounded ranges?

Created on 24 Jul 2020  路  6Comments  路  Source: chapel-lang/chapel

Summary of Problem

It seems reasonable to say myList[lo..] or myList[..hi] (or even myList[..]) yet these are not supported at present and generate a not-particularly-helpful error message. I think we should add support for these list slices, or if not, generate a more useful error message.

Steps to Reproduce

Associated Future Test(s):
test/library/standard/List/this/unboundedListSlice.chpl #16122

Configuration Information

  • Output of chpl --version: chpl version 1.23.0 pre-release (c3edd9e4d3)
Libraries / Modules Bug

Most helpful comment

Oh, do we not already support slicing a list by a range? It seemed to work with bounded ranges, which is why I assumed it was supported/intended. But maybe you're saying that it's only working by promoting the serial list accessor? (which makes the current error message make a bit more sense. I think that definitely complicates this question a little bit and gets into a larger design topic that I've been wondering about recently which is "how good is Chapel at permitting users to create aliasing views of their data structures, and do we need to do more there?"

All 6 comments

@dlongnecke-cray: For your consideration.

Sure, if we were to support slicing a list by a range, what would we expect the operation to produce? An iterator? A "ListView"?

Oh, do we not already support slicing a list by a range? It seemed to work with bounded ranges, which is why I assumed it was supported/intended. But maybe you're saying that it's only working by promoting the serial list accessor? (which makes the current error message make a bit more sense. I think that definitely complicates this question a little bit and gets into a larger design topic that I've been wondering about recently which is "how good is Chapel at permitting users to create aliasing views of their data structures, and do we need to do more there?"

I reworded the title of this issue to reflect less certainty now that I understand we didn't put in effort to support slicing.

Related to #15707 ?

Edit -- Nvm, I was looking at two different issues and got confused

It seems a little bit related to #11222 in that #11222 is arguably requesting string views/borrows and this is arguably requesting list views/borrows.

Was this page helpful?
0 / 5 - 0 ratings