-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
proposal: slices: add Channel #66409
Comments
is this a common operation that should be in the standard library? |
yes
the function creates a channel that will return data from the given slice. the resulting channel would be read by the user of this function.
channels aren't going away, and I think a big hurdle for new users is they dont "get them", so it might help to have a high visible function that uses channels. people can use the function as is, or look at the implementation to better understand a real use case of channels. |
generally, we like to see assertions backed up with evidence.
you've described the function, but that doesn't clear up the directional ambiguity.
this points to having better guides / tutorials / examples, not a new function in the standard library which may arguably not be best practice to use. |
I agree this looks dubiously useful at best. The usage example is certainly not motivating. Why put all items into a channel and iterate over the channel, instead of iterating over the slice directly? I think any path forward here would require a use case different than the one in the OP's example. Can someone provide a use case where this would simplify user code? Some pattern in real codebases would help. In any case, this needs to be declined until iterators are sorted. Any such function would take an iterator, not a slice. |
Proposal Details
a function that turns a slice into a channel:
example:
The text was updated successfully, but these errors were encountered: