Skip to content

Link to explanations of r-value, l-value and lint#152

Merged
japaric merged 2 commits into
rust-lang:masterfrom
vks:links
Jul 3, 2014
Merged

Link to explanations of r-value, l-value and lint#152
japaric merged 2 commits into
rust-lang:masterfrom
vks:links

Conversation

@vks

@vks vks commented Jul 2, 2014

Copy link
Copy Markdown
Contributor

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.

@japaric

japaric commented Jul 2, 2014

Copy link
Copy Markdown

@mdinger

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 might even want to consider explaining them in Rust by Example.

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?

@vks

vks commented Jul 2, 2014

Copy link
Copy Markdown
Contributor Author

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.

@mdinger

mdinger commented Jul 2, 2014

Copy link
Copy Markdown
Contributor

I think both links are definitely better than nothing. Neither is really bad. The text for r-value/l-value is heavy and abstract but you can understand it if you think about it. It doesn't have lots of unknown words which raise the difficulty. I would add them at least until there is a glossary or something to help out.

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.

@mdinger

mdinger commented Jul 2, 2014

Copy link
Copy Markdown
Contributor

Also, could you edit the first comment of issue #97 so that it renders as a TODO list (like issue #1)

Done

@vks

vks commented Jul 2, 2014

Copy link
Copy Markdown
Contributor Author

f(r-value?) // Doesn't work...how could you call it?

You can actually have an r-value as an argument to a function: f(9i + 4i)

(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.)

@mdinger

mdinger commented Jul 2, 2014

Copy link
Copy Markdown
Contributor

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

@japaric

japaric commented Jul 3, 2014

Copy link
Copy Markdown

Ok, let's merge this for now, until we start working on the glossary (#97)

japaric pushed a commit that referenced this pull request Jul 3, 2014
Link to explanations of r-value, l-value and lint
@japaric japaric merged commit 704a37b into rust-lang:master Jul 3, 2014
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.

3 participants