-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
RFC: Add "spaceship" operator. #3776
base: master
Are you sure you want to change the base?
Conversation
0410660
to
a53bfdb
Compare
a53bfdb
to
2b3c2fe
Compare
My feeling is that this doesn't add very much extra expressivity, especially considering the high cost of adding a new operator to the language. |
The goal of this isn't to increase expressiveness (per se); it's just to add a shorthand for an existing feature. :) |
This RFC lacks motivation other than it making code a bit shorter. We don't just add operators based on that, if we did we'd have hundreds of operators. |
In addition to the lack of motivation, the other big issue with this operator is I don't think that it's actually very obvious whether To me, having to filter out And there's also the issue that the operator returns an enum that is not in the prelude, and so we'd have to manually import it, even though the operator itself is usable in the prelude. That feels at least kind of bad, and I'd assume that adding While I think it's cool, ultimately, there are too many unanswered design questions that the RFC doesn't really try to answer. While I think that the desire to get involved is always commendable, it really doesn't feel like you've properly thought this feature out enough for it to be viable as an RFC right now. Note that this doesn't mean that I'd always be against a comparison operator, but that I feel that a substantial amount of design work would have to be done first that has not yet been done. |
You all have very compelling arguments. I will yield in that this proposal may not necessarily be mature enough for serious consideration as-is (other than the question of whether a |
Note that MIR actually does have this as a One possibility: add both Or maybe it could use a "if it's Ord for all lifetimes, it's Also, I don't think adding That said, last I did a straw poll about whether people were interested in having it, the reception was lukewarm-to-negative. So I suspect it's unlikely to land, even if I'm vaguely in favour myself. It would be nice in the derives particularly to have it avoid the extra dereference-and-inlining on primitives today that |
|
as a non-standard operator among other programming languages it would be hard to remember the spelling whether it should be |
The compiler would just tell you if you got it wrong, you'd learn in like 10 minutes probably. also it "obviously" goes at the end because in expressions it's always a postfix operator, |
that would suggest the operator should be named also the postfix
|
i see what you're saying but also emotionally i want the ? to go inside the < > pair, you know what i mean? |
This is actually why, although a similar thought to that mentioned came to mind, I actually didn't think it was a good idea after thinking about it. It feels almost like |
That's kinda fun, actually. (I'm not convinced it's actually good, though.) |
Shouldn't it be |
What about |
Rust should have a spaceship operator
<=>
for cleaner three-way comparisons.Rendered.