-
Notifications
You must be signed in to change notification settings - Fork 152
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
Send and receive only channels #170
Comments
I'm not sure if it's worth creating a wrapper type for |
Once the language can support |
@paulofaria @phausler Would this be a reasonable implementation of If so I could create a PR.
|
100% agree with the previous comment from @phausler. We could perhaps have a
It could make sense if there are several types of Channels in the future. |
Yes, but if we do not want to wait for Async types to get Primary Associated Type (PRAT) support, might be nice to get something in the mean time? It sound as if AsyncSequences getting PRAT support might take some time since it is effectively blocked by Precise Error Typing (just asked for status update) - from Swift Forums thread:
|
I think what The benefit of doing this is that it not only allows you to vend a specific interface to only the write side of things, it also allows you to implement logic inside For the places where you want to both write and consume the channel you can just pass both types. This way you also don't need a |
An important ability when passing around channels is to limit sending/receiving by passing a send-only or a receive-only channel. Right now, it is possible to erase receiving, since
AsyncChannel
is just anAsyncSequence
. However, there's currently no mechanism to create a send-only version of a channel. The simplest solution I think is to create a wrapper type calledSendingChannel
or something. I think this is a good reason to renameAsyncChannel
to justChannel
(#47). Otherwise we would haveSendingAsyncChannel
, which is not too bad, but I really think theAsync
part doesn't help us much.The text was updated successfully, but these errors were encountered: