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

Make select.case a little more readable #8165

Closed
wangkuiyi opened this issue Feb 5, 2018 · 3 comments
Closed

Make select.case a little more readable #8165

wangkuiyi opened this issue Feb 5, 2018 · 3 comments
Assignees

Comments

@wangkuiyi
Copy link
Collaborator

It looks to me that

sel = fluid.select()
with sel.read_case(ch, x):
  do_something_with(x)

is a little more readable than

sel = fluid.select()
with sel.case(ch, X, 'r'):
  do_something_with(x)

What do you think?

@helinwang
Copy link
Contributor

helinwang commented Feb 5, 2018

What is your opinion on:

sel = fluid.select()
with sel.case(ch.read(), x):
  do_something_with(x)

@kavyasrinet
Copy link

kavyasrinet commented Feb 5, 2018

I agree with both proposals.
For the first proposal, we will have to implement sel.read_case(ch, x) and sel.write_case(ch, x) methods as a part of select.
For the second proposal, we can have more consistency and can reuse concepts from channel implementation. Since in the PR: #8164 , the proposal is to make send and recv as functions of fluid instead of channel. So one proposal is:

sel = fluid.select()
with sel.case(fluid.recv(ch), x):
  do_something_with(x)

@abhinavarora
Copy link
Contributor

I agree with @wangkuiyi first proposal of using

sel = fluid.select()
with sel.read_case(ch, x):
  do_something_with(x)

@helinwang , I like your suggestion too. I am just a little skeptic that since we will have to implement it for both the cases, i.e. the standalone channel and select, we might run into complications. I think we can start off with Yi's first suggestion and then later see if we can support your design. What do you think?

@chengduoZH chengduoZH self-assigned this Feb 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants