-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Link to explanations of r-value, l-value and lint #152
Conversation
Do these wikipedia links look "good enough" to you? Or are they too general/abstract? Also, could you edit the first comment of issue #97 so that it renders as a TODO list (like issue #1)
We could add a (single page) glossary to the book, in the same spirit of the rusticon, for terms that may be unfamiliar; and then link these terms to it (using anchors). Opinions on this? |
I think the links are better than nothing (they give background on where those words come from). This pull request addresses the in my opinion worst offenders from issue #97. A better solution would be a glossary that includes one-sentence definitions and the links. |
I think both links are definitely better than nothing. Neither is really bad. The text for I tried to form their example text into code. Hopefully it emphasizes that it's mainly talking about right/left sides on an equation. You have to read pretty carefully to realize this: // This gives 13i as an `r-value` (right side) and then is discarded (not stored)
9i + 4i;
// `x` is an `l-value` (left side). The previous `r-value` is assigned to it (stored)
let x = 9i + 4i;
// A function can only call an `l-value` because it has a storage location
// An `r-value` has no storage location and therefore cannot be called
f(x)
f(`r-value?`) // Doesn't work...how could you call it? A glossary section with term definitions would probably be a good idea in the long run. |
You can actually have an r-value as an argument to a function: (This is pretty important in C++11 and it's move semantics, because r-values can be moved instead of copied (because they cannot be reused), which is more efficient.) |
Interesting. Didn't think about that. Was thinking about cases like this: 13i; // Let's pass this to f next line
f(`previous line`) // can't because it was discarded |
Ok, let's merge this for now, until we start working on the glossary (#97) |
Link to explanations of r-value, l-value and lint
I think those terms are not common knowledge for a lot of readers, so I linked the corresponding Wikipedia articles. We might even want to consider explaining them in Rust by Example.