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

Update if-let.md #38436

Merged
merged 3 commits into from Feb 6, 2017
Merged

Update if-let.md #38436

merged 3 commits into from Feb 6, 2017

Conversation

bluecereal
Copy link
Contributor

Calling if-let a combination of if and let is confusing, as some may be led to believe that it's a literal combination, instead of syntactic sugar added to the language as a convenience. What's there to stop someone from thinking if-let is just if and let together?

I do think this article does a good job of implying what's really going on; however, I was only able to notice this after I had begun to understand if/while-let statements, courtesy of the Rust IRC chat.

Basically, this article lacks the clarity and explicitness an inexperienced programmer like me needs in order to understand the contents fully. This is shown by my inability to understand the if-let concept from this page of the Book alone.

I think convenience, sugar, and (if-let != if + let) should all be made mention of in a clear, explicit manner. I lack confidence in my understanding of this issue, so I wrote just enough to hopefully get my thoughts across.

Calling if-let a combination of if and let is confusing, as some may be led to believe that it's a literal combination, instead of syntactic sugar added to the language as a convenience.  What's there to stop someone from thinking if-let is just if and let together?  

I do think this article does a good job of implying what's really going on; however, I was only able to notice this after I had begun to understand if/while-let statements, courtesy of the Rust IRC chat.  

Basically, this article lacks the clarity and explicitness an inexperienced programmer like me needs in order to understand the contents fully.  This is shown by my inability to understand the if-let concept from this page of the Book alone.  

I think convenience, sugar, and (if-let != if + let) should all be made mention of in a clear, explicit manner. I lack confidence in my understanding of this issue, so I wrote just enough to hopefully get my thoughts across.
@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @steveklabnik (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@frewsxcv
Copy link
Member

frewsxcv commented Dec 18, 2016

Thanks for the PR and feedback about this section! I can see how it might be misleading to compare if let directly with if and let. My worry with your changes is that it makes this whole section a little worried wordy. What about if we removed the comparison to if and let and just opened with the following sentence:

if let allows us to match [patterns] within the condition of an [if].

For example, let’s say...(and so on)

[patterns]: https://doc.rust-lang.org/book/patterns.html
[if]: https://doc.rust-lang.org/book/if.html

EDIT: typo

`if let` allows you to combine `if` and `let` together to reduce the overhead
of certain kinds of pattern matches.
`if let` is a figurative combination of `if` and `let`. `if let` does not literally
mean `if` + `let` to the compiler; it has its own special meaning,which was added for
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs a space after ,

@steveklabnik
Copy link
Member

steveklabnik commented Dec 22, 2016

r? @frewsxcv

@bluecereal
Copy link
Contributor Author

I added what you suggested @frewsxcv, plus an extra sentence about overhead and convenience because I thought it might help the reader understand the rest of the page better, I'm unsure, however; maybe it adds more complexity than necessary. What do you think?

@frewsxcv
Copy link
Member

Your changes look good to me, thanks!

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jan 21, 2017

📌 Commit ebf07da has been approved by frewsxcv

`if let` allows you to combine `if` and `let` together to reduce the overhead
of certain kinds of pattern matches.
`if let` allows us to match [patterns][patterns] within the condition of an [if][if].
As a consequence, we reduce the overhead of certain kinds of [pattern][patterns] matches
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After thinking about it more, I'm not a huge fan of the word "consequence" here since it usually describes the results of an action, and there's not really an action here. What about:

if let allows us to reduce...

or

This feature allows to reduce...

or

This allows us to reduce...

or something else. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about this? I'd rather avoid using allow twice like that.

if let permits pattern matching within the condition of an if statement.
This allows us to reduce the overhead of certain kinds of [pattern][patterns] matches
and express them in a more convenient way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds great :)

@frewsxcv
Copy link
Member

@bors r-

@alexcrichton
Copy link
Member

ping @bluecereal, want to make the update @frewsxcv mentioned?

@frewsxcv
Copy link
Member

frewsxcv commented Feb 6, 2017

Looks great, thanks for being patient with this! 🎉

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Feb 6, 2017

📌 Commit fb7f211 has been approved by frewsxcv

@bors
Copy link
Contributor

bors commented Feb 6, 2017

⌛ Testing commit fb7f211 with merge 4711ac3...

bors added a commit that referenced this pull request Feb 6, 2017
Update if-let.md

Calling if-let a combination of if and let is confusing, as some may be led to believe that it's a literal combination, instead of syntactic sugar added to the language as a convenience.  What's there to stop someone from thinking if-let is just if and let together?

I do think this article does a good job of implying what's really going on; however, I was only able to notice this after I had begun to understand if/while-let statements, courtesy of the Rust IRC chat.

Basically, this article lacks the clarity and explicitness an inexperienced programmer like me needs in order to understand the contents fully.  This is shown by my inability to understand the if-let concept from this page of the Book alone.

I think convenience, sugar, and (if-let != if + let) should all be made mention of in a clear, explicit manner. I lack confidence in my understanding of this issue, so I wrote just enough to hopefully get my thoughts across.
@bors
Copy link
Contributor

bors commented Feb 6, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: frewsxcv
Pushing 4711ac3 to master...

@bors bors merged commit fb7f211 into rust-lang:master Feb 6, 2017
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

Successfully merging this pull request may close these issues.

None yet

6 participants