Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Unimplemented feature]: Zippering an array of ranges with something else doesn't work #26618

Closed
lydia-duncan opened this issue Jan 29, 2025 · 4 comments

Comments

@lydia-duncan
Copy link
Member

lydia-duncan commented Jan 29, 2025

Summary of Problem

Description:
I obtained an array of ranges (populated by calling the range type's leader iterator for a larger, single range). I wanted to make an array storing the size of each range in that first array. Several of the things I tried did not work out, one of which is detailed below and involved zippering the contents of the first array with its index set. It gave the message "Heterogeneous tuples don't support this style of loop yet".

I was able to work around this by iterating over just the index set. It would have been nice for more strategies to have worked.

Is this issue currently blocking your progress?
no

Steps to Reproduce

Source Code:

// Motivated by getting the subranges from the range leader iterator
var arr: [0..4] range = [1..2, 3..4, 6..7, 5..5, -1..0];

writeln(arr);

var arr2: [arr.domain] int;

// I wanted to store the size of each of the ranges into a separate array, but
// writing it like this didn't work.
forall (i, r) in (arr.domain, arr) {
  arr2[i] = r.size;
}
/* Had to use this instead:
for i in arr.domain {
  arr2[i] = arr[i].size;
}
*/

writeln(arr2);

Compile command:
chpl foo.chpl

Execution command:
N/A

Associated Future Test(s):
test/types/range/arrayOfRanges.chpl #26619

Configuration Information

  • Output of chpl --version: 2.4.0 pre-release
  • Output of $CHPL_HOME/util/printchplenv --anonymize: any
  • Back-end compiler and version, e.g. gcc --version or clang --version: any
  • (For Cray systems only) Output of module list: N/A
lydia-duncan added a commit that referenced this issue Jan 29, 2025
[minor new tests, not reviewed]

One was while trying to sort the array, the other was trying to use it
in a zippered context

Relates to issue #26616 and #26618

Verified a fresh checkout of the futures
@bradcray
Copy link
Member

I think you went old-school Chapel and forgot the zip() keyword here:

forall (i, r) in (arr.domain, arr) {

(should be:

forall (i, r) in zip(arr.domain, arr) {

?)

@lydia-duncan
Copy link
Member Author

D'oh!

@lydia-duncan
Copy link
Member Author

I wonder if there's a way we can make that more obvious . . .

@bradcray
Copy link
Member

I think the error message is pretty accurate as currently worded, but it may be able to be clarified further. I probably wouldn't go so far as to have it refer to the old pre-zip syntax, since that's probably only going to be meaningful to a few people like you and me who often make this mistake, and less so to contemporary Chapel users (unless there's a notable language that relies on tuples for zippering; I think the argument that led us to add zip() was that that's what most did, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants