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

Chapel's list type should support initialization from an iterator expression #16166

Closed
bradcray opened this issue Jul 29, 2020 · 5 comments
Closed

Comments

@bradcray
Copy link
Member

It seems like it would be convenient / natural to have Chapel's list type support initialization from an initializer expression as follows:

var l: list(t) = myIterYieldingTypeT();

Is there a reason we wouldn't want to that I'm not seeing?

If not, this seems as though it could be implemented by defining an init= for list taking an _iteratorRecord?

@mppf
Copy link
Member

mppf commented Sep 8, 2020

After PR #16180 we could alternatively adjust proc init=(other: [?d] this.type.eltType) to use the in intent which should also allow it.

@bradcray
Copy link
Member Author

bradcray commented Sep 8, 2020

Would that have the effect of manifesting the array in memory prior to assigning it to the list? (where I'm guessing it would be cheaper to just traverse the iterator and insert the elements one by one?)

@mppf
Copy link
Member

mppf commented Sep 8, 2020

@bradcray - yes it would - as a result I would agree that the _iteratorRecord would be better for performance.

@mppf
Copy link
Member

mppf commented Nov 16, 2020

Would that have the effect of manifesting the array in memory prior to assigning it to the list? (where I'm guessing it would be cheaper to just traverse the iterator and insert the elements one by one?)

Actually, using the in intent would solve #13583. However the array copy involved is probably not desired.

mppf added a commit to mppf/chapel that referenced this issue Nov 16, 2020
For issue chapel-lang#16166

---
Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
mppf added a commit that referenced this issue Nov 16, 2020
Improve copy initializers for list

* Make List's checkType return param since it just calls compilerError 
  calls there is no need for it to exist at runtime.
* Adjust list init= to be more flexible to handle issue #16706
* Add list init/init= from iterator expr for issue #16166

Reviewed by @dlongnecke-cray - thanks!
 
- [x] full local testing
@mppf
Copy link
Member

mppf commented Nov 16, 2020

PR #16708 adds the overload for init=. (We don't have the corresponding proc = overload yet and issue #16714 asks if list should allow cross-type assignments).

@mppf mppf closed this as completed Nov 16, 2020
CaptainSharf pushed a commit to CaptainSharf/chapel that referenced this issue Jan 16, 2021
For issue chapel-lang#16166

---
Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>

Signed-off-by: CaptainSharf <mohdsharf7407@gail.com>
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