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

[transmit-case] Ergonomics for Choice<N> bounds #100

Open
sdleffler opened this issue Apr 12, 2021 · 0 comments · May be fixed by #98
Open

[transmit-case] Ergonomics for Choice<N> bounds #100

sdleffler opened this issue Apr 12, 2021 · 0 comments · May be fixed by #98
Labels
enhancement New feature or request

Comments

@sdleffler
Copy link
Contributor

Just dumping some thoughts from DMs into a more permanent location.

Currently the issue is that Choice<N> is treated specially when it cannot be, as it is quantified
and the vast majority of types which will be sent via TransmitCase will not be. At current, the
TransmitCase impl for Choice<N> is for all types Choice<LENGTH> for all const LENGTH: usize,
given a TransmitChoice impl. If we keep TransmitCase, add a NotChoice<T> type used for
transmitting non-Choice<N> types, and then add an impl for TransmitCase<NotChoice<T>>
where T: Match + Transmittable, Self: Transmit<T> and then seal TransmitCase, we can provide two
functions for choose which work for Choice<N> and NotChoice<T>. In this case it becomes very
clear how Choice and non-Choice case choosing is so different; they are of different kinds,
specifically one is a parameter of the const usize kind and the other is a type.

However, unless we extend this sealed type distinction to the type-level session language, we are
now forced to have two different variations of the offer! macro. So I propose the following:

  • Restrict types allowed in Choose and Offer types to Choice<N> and NotChoice<T>.
  • Generate the appropriate output type from the Session! macro, which has the necessary
    information to deal with this.
  • Implement Match for NotChoice<T> transparently delegating to the wrapped value.

Given this, the same offer! will happily work for both cases. And we would likely also be able to
have a single implementation of choose that works for both cases as well.

@sdleffler sdleffler added the enhancement New feature or request label Apr 12, 2021
sdleffler added a commit that referenced this issue Apr 12, 2021
sdleffler added a commit that referenced this issue Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant