-
Notifications
You must be signed in to change notification settings - Fork 636
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
Can we find a better name for select? #760
Comments
I think one suggested by @aturon historically as well has been |
|
It's true yeah it may not still be perfect, but I personally sort of like what |
I think I would be quite satisfied with |
Ok! @KasMA1990 want to send a PR for this? |
Sure! Against the 0.2 branch? |
Indeed! |
What about Just to make sure I understand them correctly: I have a few questions:
Based on this understanding, what about, instead of What do you think? Bonus question: Both |
Another question: I think Thoughts? EDIT: For precedent, Rx uses merge as the name for their equivalent method. |
I just realized that 0.1 already had a I'd also suggest renaming |
|
I agree, though I'm not sure what the best fix is. If we want to limit how many renames we do, we need a replacement for On the other hand, if we're not shy about getting better names for combinators while we're at it, I'd suggest renaming I'd go for the latter personally. And sorry for making such a fuss about a few function names, but I really think we can make a useful difference here :) EDIT: Or maybe just EDIT2: Since |
It's worth noting that |
Yeah, that was actually what started this whole ordeal; I proposed a name change in the RFC, because I had trouble figuring out what My issue with I realize changing names of functions introduces churn, and in this case also brings some inconsistency with crossbeam, but I can't help but feel that @alexcrichton I would like more input before I start actually making any changes :) |
Or maybe you've got some input @aturon? :) |
Personally, I don't think Java futures use: "all_of" for join and "any_of" for select. |
I like |
Sorry, I have to back off from this task; I hope we can still get some good names for these methods though :) |
I was recently reading C# async/await docs and saw I wonder whether these would be better as just free functions, rather than methods? Then we could call them |
@aturon yes, i think they should actually be macros (so that they can be variadic). |
Doing them as macros with varargs would make it all much more sensible to me as well, since we wouldn't need the |
I'm not quite sure what you mean by this-- if you mean they won't be usable in method position, then yes-- that's correct. |
As prior precedent, JavaScript's I do wonder if the 2-ary |
@Nemo157 I handle timeouts in fuchsia w/ a |
Punting from the initial 0.2 release; let's figure out a macro and then we can deprecate/remove these. |
Hey guys. I wonder if you still plan rename these methods. I agree that they are quite not perfect now.
|
@Pzixel The current versions of these combinators in 0.3 are still called async {
select! {
thing1 => ...
thing2 => ...
}
...
let (a, b, c) = join!(a, b, c);
} IMO none of |
@cramertj afaik select/join was picked because of C inheritage. But for people that don't know C (and there is plenty of them, including myself) it's confusing. |
I personally prefer |
I'm gonna go ahead and close this-- people know this utility as |
I think
In summary:
The danger lies in people believing that our select! {
_ = rx1.recv() => {}
_ = rx2.recv() => {}
} A Go programmer might believe only one of these operations will be executed, which would be a wrong assumption, potentially leading to difficult-to-find bugs. The name "race" might be a better choice because it sort of implies that all operations start and then we wait until one of them "wins the race". To me, "select" sounds like "pick one of these operations", which is not at all what our |
@stjepang you are right, but it's unlikely anobody will change this. |
This seems wrong. |
Right, but just because a future is not polled anymore does not mean the operation it is driving has not started or that it will not complete. The point is that all futures may get polled, and therefore all operations might complete (e.g. imagine we're selecting over a bunch of filesystem operations implemented using a blocking thread pool). There's not much we can assume about the difference between polling a future once and polling a future to completion. |
@stjepang You are certainly right on that one. But I think the point that Futures might continue to run in the background is more a general Rust Future thingy, and not specific to select! All Futures which are not purely readiness based will show that symptom, independent whether they are used in select or any other mechanism which might not drive the Future to completion. |
If you're not using |
When the crossbeam-channel RFC was introduced a few months ago, I found it very hard to understand what
select
meant. I have the same issue in future-rs, where I find the name equally as opaque as in crossbeam. Luckily I have since been pointed in the direction of some Unix history which explains the design and naming behindselect
, but I feel like we can still do better than requiring a history lesson for a function name to make sense.Therefore I would like to propose that
select
is slightly renamed to make it more clear what it is actually doing, to e.g.select_any
orselect_any_ready
maybe (or any other name that is deemed better). Although the presence ofselect_ok
already makes the naming tough, and not having a pureselect
breaks somewhat with the precedent for this functionality (since it is named as such in Unix and Go for example), but I think there are many Rust users who are not familiar with these precedents and will hence be confused by the name (myself included). At the same time, by keeping the word "select" in the name, it is still easy to search for, for those that do know the precedent (and if "select" is kept as the first part of the name, anyone just looking to type select in their IDE will also be helped by autocomplete).I feel this would be a very rustic improvement to make; it should still be easy for veterans to use, but welcomes newcomers at the same time, by optimizing for readability over familiarity.
The text was updated successfully, but these errors were encountered: