Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upUnless/Until RFC #2384
Conversation
myrrlyn
added some commits
Apr 2, 2018
Centril
added
the
T-lang
label
Apr 2, 2018
softprops
reviewed
Apr 2, 2018
| } | ||
| ``` | ||
|
|
||
| evalueates the conditional `COND`, executing the loop if the test failed and |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
guizmaii
commented
Apr 2, 2018
•
|
Hi, I'm not (for now at least) a Rust user. I'm mostly a Scala developer these days and I'm a former Java and Ruby developer. As a former Ruby developer, I can say that, IMO, the People tend to write very bad code with this keyword. Adding a lot of double negations where a simple This keyword adds more complexity in the code than producing any good effect on written code. Jules |
This comment has been minimized.
This comment has been minimized.
|
At present, I fully agree that
Lastly, in my own work with Ruby, I have found |
This comment has been minimized.
This comment has been minimized.
|
Re negative pattern matching, this has been discussed some over in #929 (comment), and I know @petrochenkov has been working on more expressive |
Centril
added
the
I-nominated
label
Apr 2, 2018
This comment has been minimized.
This comment has been minimized.
|
Nominating for triage during the next lang-team meeting on Thursday as we need to deal with any keyword reservations speedily. |
This comment has been minimized.
This comment has been minimized.
|
@jonhoo, honestly, I expect that this will wind up being primarily a driver for a full Boolean algebra on patterns. Short of |
This comment has been minimized.
This comment has been minimized.
|
This RFC represents a lot of what I was afraid of when epochs/editions were proposed. The only thing worse than a breaking change to support a feature is a breaking change "just in case". While I can't find the exact line (#2052 was a long RFC), there is text in that RFC along the lines of "epochs allowing minor breaking changes should not be used as an excuse to make breaking changes". This RFC feels like the direct antithesis of that. |
petrochenkov
reviewed
Apr 2, 2018
| } | ||
| else { | ||
| // do significant work on the positive execution | ||
| } |
This comment has been minimized.
This comment has been minimized.
petrochenkov
Apr 2, 2018
Contributor
if !(execute_machine() is FsmState::Stop) { ... }
if execute_machine() is not FsmState::Stop { ... }
if execute_machine() !is FsmState::Stop { ... }
This comment has been minimized.
This comment has been minimized.
Manishearth
reviewed
Apr 3, 2018
| "these two concepts are logically equivalent" (`Eq` trait, `==` and `!=` | ||
| operators) and "this value is shaped like that pattern" (`let`, `match`). | ||
|
|
||
| Another concept is to introduce a *negative binding*, `!let`, which does not |
This comment has been minimized.
This comment has been minimized.
Manishearth
Apr 3, 2018
Member
I personally would like to go all out and have both if !let ... and if let ... && ... work, making let in a conditional expression basically a matches! with binding. However, this does make "let-as-expression" more of a thing but it's still this weird kind of expression that's only an expression in certain contexts. So idk.
This comment has been minimized.
This comment has been minimized.
AlexEne
commented
Apr 3, 2018
•
|
Let's start from this example (from the rfc):
Is unless a while not, or a if not? Skimming over the code can confuse newbies, or even seasoned developers that didn't get a chance to see this construct before. Now let's imagine the following to be possible and valid code:
The first example already confuses me, but the second being an option is super scary me and probably any newcomers. if/while statements can get really ugly as they are now in programming, negating everything with some keywords and allowing boolean expressions inside them but reversing the meaning of the blocks executed is something that may not be worth for the benefits it brings. Probably a better option would like to make |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Pistahh
commented
Apr 3, 2018
|
In some (human) languages there is no direct one word translation for "unless", e.g. in my native language (hungarian) it is roughly translated to "if not only". Each time when I see "unless" in some code (I had Perl in my past) I have to stop, then negate the whole expression in my head and pretend that it was an "if" statement. It is even more hard and confusing if it has "not" after an "and"/"or". Having the same condition with "if" may be more complicated, but at least it is written down. And I heard the same complain from some British people too. "Unless" may look simpler if the condition is simple, but once it has more components, some negated, some not, it just becomes extra complicated to understand. With these in mind, please consider that for me most of the examples demonstrating how "unless" would make code simpler makes it actually harder to understand. Please keep the language simple. "Unless" just complicates it. |
This comment has been minimized.
This comment has been minimized.
|
I agree with @sgrif's comment strongly. There seems to be a rush to block things for edition 2018 to allow RFCs to be written on top of these that might themselves not succeed. I also see a high chance that This should either be run as a fully-fledged RFC, with the goal for implementation being edition 2018, or none. Currently, it's only a collection of (advanced) reasoning why such a change could be useful, but at the end only argues for blocking these words, as they could be used for something. This is definitely a weak reasoning for a change that will likely have practical impact when porting over to 2018. Also, an argument for |
This comment has been minimized.
This comment has been minimized.
|
I have always found |
This comment has been minimized.
This comment has been minimized.
|
I'm really, really against IMHO, just take these keywords and bury them; Ruby and CoffeeScript have them but even in those languages I prefer to not use them because of the above reasons |
This comment has been minimized.
This comment has been minimized.
Ichoran
commented
Apr 3, 2018
•
|
If there are places where logical inversion is not readily accessible, let's make it accessible rather than adding new keywords. For instance, if there were a "bool-let-expr" where any let statements act as pattern matches that are true if they succeed and add the bound variables (if true and universal) to both the rest of the expression and the following block, then you would get full boolean algebra with pattern matching, and no extra keywords. |
This comment has been minimized.
This comment has been minimized.
|
@skade that came off as way angrier than I intended; I've edited my comment. :) |
This comment has been minimized.
This comment has been minimized.
|
I'm definitely opposed to " The version of this I could like, and have articulated before, is for guards. Note, for example, that Edit: As another example, failure's |
This comment has been minimized.
This comment has been minimized.
pwoolcoc
commented
Apr 4, 2018
|
I'll join in with the comments against this. I've done perl professionally and, though I eventually trained myself to replace "unless" with "if not" in my head, it's just extra cognitive load that is unnecessary. I do wish rust had gone with keywords for |
nikomatsakis
removed
the
I-nominated
label
Apr 12, 2018
Centril
self-assigned this
Apr 12, 2018
This comment has been minimized.
This comment has been minimized.
|
We discussed this in the @rust-lang/lang meeting today, and the general consensus was to close. Nobody was particularly enthusiastic about this change, or about seeing the language go in this direction. (There was a little bit of discussion about specific use cases or aspects of matching, related to some of the @rfcbot fcp close |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Apr 12, 2018
•
|
Team member @joshtriplett has proposed to close this. The next step is review by the rest of the tagged teams: No concerns currently listed. Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
rfcbot
added
the
proposed-final-comment-period
label
Apr 12, 2018
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Apr 19, 2018
|
|
rfcbot
added
final-comment-period
and removed
proposed-final-comment-period
labels
Apr 19, 2018
This comment has been minimized.
This comment has been minimized.
warlord500
commented
Apr 20, 2018
|
the only advantage, I could really see if is that unless and until are used to express negative patterns, adding more ways to do a thing, usually just leads to trouble. the only major reason, you should have multiple ways to do things if that specific that method reduces boiler plate for a common purpose. I have no problem reading many conditions with not in it. many times there is a question of where to put the not but adding one more certainly wont help. |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Apr 29, 2018
|
The final comment period is now complete. |
This comment has been minimized.
This comment has been minimized.
|
Thank you @myrrlyn for the RFC! Per review #2384 (comment), this RFC is hereby closed. |
myrrlyn commentedApr 2, 2018
This RFC reserves two keywords for the next available period of keyword reservation. The
unlessanduntilkeywords act as logical inverses ofifandwhile, and are intended for use where inversion of the condition being tested is not readily available.Rendered